The work visa system in the US seems to create this stress because there's no automatic transition between states. You get a fixed, short period of unlimited work after graduating but then you need a job to sponsor you, which will most likely be as a "nonimmigrant" that has to be renewed and updated when you change jobs. And that never converts to a green card on its own, the employer has to start over with a new process and prove that no US workers are available to do the job.
In other countries (not sure about Europe), it's more like you get a work visa the first time, you keep working for 5-7 years, then you automatically get a permanent residence and can change jobs freely (or retire, study, etc.).
You do have a valid concern about what happens if you job ends, but I think in that case a good backup plan is just to apply for schools in Europe. Not sure how the timing would work out with admission cycles or how strict they are about how long you can stay before finding a new job/switching to student though.
You could even see if the US university would be willing to defer your admission for a year to do a "gap year" of work experience? That's kinda sort of a thing in the US, so it's worth asking.