WD-40 is primarily kerosene.
Most aerosol "electronic contact cleaners" are primarily isopropyl alcohol with some naptha/butane - (many include other related proprietary chemical blends).
The "plastic safe" contact cleaners are generally 'safe' for our choo-choos are primarily isopropyl alcohol.
Old-fashioned mineral spirits are maybe the safest option for cleaning pre&post war motors and commutators. The varnish/shellac insulation on the motor windings that old pre&post war motors were made with can be spoiled by alcohol.