Are the cells IN the train. If there are two in series then 2 x AA will probably work and you are very unlikely to do damage by trying them.
You can buy sleeves that an AA battery is inserted to making it the same physical size as a D cell as seen here.
Operating lifetime and peak current will be less and they MAY not have enough current capability to start the motor in some cases.
Use either Alkaline non-rechargeable or high capacity NimH.
@FakeMoustache suggests that you should not put multiple AA cells in parallel. Doing so is usually considered unwise but MAY be viable with reservations. If you do so they MUST be all at the same state of charge. ie putting 2 or 3 fully charged batteries in parallel will probably not cause major problems. Doing so will possibly shorten the cycle life of the batteries.
If connecting batteries in parallel, it would be wise to insert 2 or 3 batteries in to a holder in parallel, leave them for a few minutes and then check whether there is any noticeable heating. Also check voltage of the 3 with a meter. If this works OK the first few times it will PROBABLY continue to do so.
While the chance of fire is small if all batteries are equally charged, if safety or the life of the locomotive is of concern then you may be wiser not to use this method. (I would, with due care). YMMV.