An alignment

I was told that an alignment is necessary only when a car gets 4 new tires. I thought whenever all tires are detached and reattached (like rotating tires), an alignment would be necessary.
Why only with new tires? Wouldn’t it be unsafe if all four tires are reattached without an alignment?

Getting new tires doesn’t change the allignment.

An alignment is needed any time the wheels are no longer properly aligned.

Getting an alignment with new tires is a good idea, and cheap insurance against uneven wear, but there may be other times when an alignment is necessary.

Some people have their alignment checked annually, or every few years, just to make sure it’s still OK. Potholes, rough roads, impacts with curbs, etc, can knock the wheels out of alignment.

Rotating the tires to a different position on the vehicle does not, however, necessitate an alignment.

Tires, new or used, have nothing to do with the alignment. The purpose of an alignment when getting new tires is to simply make sure there is nothing out of whack which may eat up those new tires.
Having an alignment check and inspecting the suspension every 40-50k miles is a good idea and more often if an alignment problem is suspected.

Many years ago my father had an alignment problem on his car and took it in for a new set of tires and alignment as he was about to go on a vacation.
When he arrived at his destination 900 miles later he discovered the 2 new front tires were worn clean out already and the shop there discovered that the tie rod adjusters (the most basic of the alignment procedure) were still slightly rusted over and had never been touched.

As others have already stated putting new tires on or rotating the tires won’t change the alignment, but anytime new front end components have been put on such as tie rod ends, struts, or ball joints this will affect the alignment and will need to be adjusted and brought back to specs.

You can search the internet for pictures of odd tire wear patterns due to auto wheel misalignment to educate your eyes to watch for that. Some odd tire wear can be attributed to overly fast cornering if you do that so you will need to know the difference. An inexpensive tire tread depth gauge might help. With such knowledge, you can stop wondering if you need a front or rear wheel alignment to save a few dollars for unneeded work. I drove my last car to well over 150,000 miles to trade-in with no alignment needed. We have also owned several other cars to varying mileages at trade-in with never a wheel alignment.

It is possible that misalignment will indicate itself if the vehicle pulls to the left or right but not always.

Wheels pretty much stay in alignment if you don’t have worn steering parts and you do not have an incident such as hitting a very deep pothole or bump with the brakes heavily applied, hitting a parking curb too hard or slide sideways into a street curb in slippery weather.

The bottom line is that a little education for your eyesight as well as reasonably careful use of your vehicle can get you out of the dark unknown regarding the need for wheel alignments.