Actually, unless the car is front-engine/rear-wheel-drive, the reason is usually due to space concerns.
For example, Subarus always have longitudinal engines with their boxer-4's, even when they still had FWD models. OTOH, a Mitsu EVO is tranverse with it's I-4 even though it is AWD. Those are just examples.
Front-engine/rear-wheel-drive vehicles will never have transverse engine because it simply wouldn't make sense. The power from the engine would have to turn a right angle to travel down the driveline, only to do the same again at the rear wheels.
As ZV mentioned, weight is another concern. A longitudinal FWD can balance the weight of the engine in front of the front wheels with the weight of the transmission behind the front wheels. A transverse engine can't do that.
There is also a belief that longitudinal provides a smooth transmission of power because there are fewer right angles in the drivetrain.
But usually, space is the real reason. For example, a transverse engine allows for a short low hood with no transmission poking into the passenger compartment.