To be certain, you need to verify the transmission part numbers. Find the transmission part number on both the Grand Marquis transmission and the Town Car you intend to install it in. If the numbers match exactly, then it's likely compatible. Even a slight variation could indicate incompatibility.
You should also check the transmission's compatibility with the Town Car's engine. Even if the transmissions physically fit, the torque converter and other internal components might not be appropriate for the Town Car's engine.
In short: Don't assume compatibility. Check the part numbers first!