Welcome to the forum!
If you have '027' or '0' gauge track, you need to pull the pins out of the end of the track, then use a needle nose pliers to squeeze the track at the base under the hole to close the hole slightly. Then reinsert the pin. Squeeze the track the same way on the opposite end of the track, then the mating track will be a tight fit.
There are also special track clips that snap under the tracks at each joint to hold the track in place, if you need them.
https://www.amazon.com/Lionel-027-Track-Clips-pack/dp/B000BVL3UYLarry