Here's an answer I found on reddit as it relates to tanks:
https://www.reddit.com/r/AskEngineers/comments/6mxzo8/comment/dk5t5ss/
There's several pros and cons of each setup and it's one of those
things for which there's probably not a 'correct' location. Several
have already been mentioned but off the top of my head:
Drive sprockets at the front:
Pros:
Gearbox next to the driver so system for gear changing is simpler to
implement
Gearbox at the front gives a big block of metal between incoming fire
and the crew for additional crew protection (this reason often given
for layout of WW2 German designs and the Merkava)
Returning tracks will shed mud, sand etc before they reach the drive
sprockets so wear on tracks and sprockets is reduced
Cons:
A design with rear engine and front gearbox requires a driveshaft to
pass through or under the fighting compartment. This either reduces
internal space or requires a taller profile.
Hits to the front are more likely to damage drivetrain components and
make it harder to salvage the tank.
Drive sprockets at the rear:
Pros:
Engine and gearbox can be packaged together at the rear, giving a
smaller and lower tank. This often makes maintenance and repairs
simpler as engine and gearbox can both be accessed through the rear
deck
Hits to the front are less likely to damage drivetrain components and
so tank is likely easier to salvage after being knocked out (this is
only really an advantage if crew members are cheap and you don't mind
using them as extra armour for your expensive tank)
Cons:
Tracks hit sprockets immediately after leaving the ground so are
likely to be covered in mud etc which is then forced through the drive
tooth contacts, increasing wear rate
More mechanical complexity in changing gear as the driver must control
a gearbox at the rear from his position at the front