Public hospitals treat foreigners essentially everywhere; emergency care in particular won't be refused while you're being stabilized, and in many countries public emergency departments are exactly where an ambulance takes you regardless of nationality. The differences show up in payment and experience rather than admission.
On payment: as a non-resident you typically aren't covered by the public system's funding, so you're billed as a private payer, at rates that range from remarkably cheap to substantial depending on the country. Many public hospitals ask foreigners for a deposit or card details at registration for non-critical treatment, and settlement is expected before discharge. Travel insurance helps most smoothly when its assistance company issues a guarantee of payment, though not every public hospital handles direct billing with foreign insurers; you may pay and claim reimbursement, so keep every document.
Experience-wise, public hospitals can mean longer waits, less English, and busier wards than private alternatives, but often perfectly good medicine; in many countries the top specialists work in the big public teaching hospitals.