My transit system (Tri-Met, metro Portland, Oregon) has the Portland & Western R. R. (more)3 run self propelled commuter coaches (diesel multiple units, DMU) on a freight line; sometimes solo, sometimes with an unpowered control car coupled to the car with the power pack. The car with the power pack is forward half the time, aft half the time. Is it safer to be in the powered coach in the event of derailment or collision? In which part of that coach? This is different from other question about safety, because they addressed exclusively unpowered coaches; in this situation, we have one car with extra mass (which might help) vs diesel fuel and an attendant fire risk.
It's pretty small marginals we're talking about (trains hardly ever crash in the first place), but I don't think the type of car matters as much as where in the train.
Most collisions involve the front end of at least one train -- and most derailments involve something going wrong with the first bogie, since that will meet hazards on the track first. So for a two-car train the rear car will be relatively less likely to be directly involved in an accident.
(Diesel fuel is pretty hard to ignite; I've never heard of a train accident where a fuel fire was a determining factor).
I'll second sitting towards the rear as mentioned in the excellent answer by Henning Makholm (train crashes in the US, as far as I know, are most usually collisions between trains and things that aren't trains that have no business being in the track (eg at level ("grade") crossings); or derailments, both of which are going to affect the front of the train more than the rear).
But I also wanted to add that if your system has seats facing in both directions (I know many American systems have seats all facing the same direction and complicated methods of turning the train or flipping the seats around), it's also much more survivable to sit with your back facing the direction of travel. If you hit something you will be thrown into your seat, rather than across the train and into various, much less soft, obstacles or (worse) out of a broken window or door.
In most countries though I wouldn't bother with such things. Rail accidents are rare and if it means ruining your enjoyment of the journey by sitting in a more crowded part of the train or in a seat you don't like (even if it's safer), I'd much prefer to just take the minuscule risk.
My first instinct was to go with "sit in the back" as the two (current) answers advise. However, since they're already here, I'll add a counter point that sometimes there is a collision between two trains that are on the same block of track when they shouldn't be.
Being in the back of train would be the best-bet if you're in the train doing the rear-ending, however, being in the front of the train if you in the one being rear-ended is going to be your best bet.
i.e. There's not much you can do to protect yourself in a train accident. Much like commercial aircraft operations, the odds of being in an accident in the first place are pretty darn small. The best you can do is not stress over something that has an incredibly small chance of happening.
NOTE: Advice does not apply if the operator has an unacceptably high accident rate. In that case, take the bus.