It's not just the homeless, it's anyone without insurance.
Assuming for the moment that someone who is in an emergency situation has the presence of mind to try an concoct a scam...it usually wouldn't work. There are lots of reasons for that.
Let's say you're hit by a car, and taken by ambulance to the nearest hospital. They will treat you, but then...The hospital would require a social security number, and with electronic databases and HIPAA, they would probably find your true identity quickly. After the emergency phase has passed, a hospital social worker or some such person would be assigned to the case, and do some digging. They pursue payment vigorously while you're in recovery. They would see if you qualify for any federal programs (like Medicare) and have you enroll. Or they would transfer you as quickly as medically possibly to a public hospital (like a county facility) which receives federal funding for the uninsured (called an FQHC facility).
You would rack up hospital bills under that social security number, and receive many bills in the mail (whatever address you give). An electronic health record would be generated, with identifying information.
In other words, it's not just a walk-in, walk-out kind of thing. The hospitals work very hard to prevent that kind of fraud (hell, I have to show my medical card, AND my driver's license just for regular doctor visits).
If you have insurance, the co-payment for emergency room care is usually pretty small (ours is $50, some go as high as $500. Not bad compared to the usual $10,000 - $30,000 bill). It's not worth committing fraud to get "free" care in some dismal government facility.