This is often organised beforehand – an ambulance will call ahead to ensure there is space where they are headed to, and if not can be diverted elsewhere.
Emergency rooms also won’t run a strict first come, first served approach, but will instead triage patients – when a patient enters they will be given a quick evaluation regarding how serious and life threatening their condition is – so a patient that is bleeding out and needing immediate care will be jumped straight to the head of the queue and treated straight away. But the person with the broken arm that may be in a lot of pain, but not at risk of immediate death will be left waiting until they have the capacity to deal with them.
This is why there can sometimes be long waits in emergency departments – at busier times lesser cases may be repeatedly bumped back in line to make way for the true emergencies.
Ambulances won’t necessarily soup the queue though – in general people only call ambulances for serious injuries so they normally get pretty immediate attention, but should other cases take priority there can be a wait to unload the ambulances and take the patient in for further treatment.
The waiting room might be full not because there are no beds available, but because there isn’t enough staff to see everyone. In a typical metropolitan there are multiple hospitals. And while they all might have all the medical equipment necessary some hospitals specialize in certain types of critical issues
So one hospital might have a larger trans center to deal with the industrial and auto accidents, another might have a better cardio center. The paramedics know this and will be in radio communication to go to the better one either based on proximity or quality of facility.
So the hospital A might have the trama operating room available even though the waiting room is full. The person waiting outside because of a twisted ankle will get bumped to a lower priority because someone from a bad car crash is coming in via ambulance.
In medical parlance it’s called triage, treat based on most serious first or most likely to survive.
They typically don’t. They will direct the ambulance to send the patient to a different hospital. But if there is no other choice, such as during a major emergency situation then non ER rooms will be utilized by the ER staff as needed/able. They may even do basic triage and some treatments in hallways if necessary.
Latest Answers