I was driving west on S Holgate, crossing the railroad tracks between 4th and 2nd, when the collision avoidance system began to sound even though nothing was in front of me. The car CAS then initiated an emergency stop on the tracks. Just then the train crossing started flashing red so a car following me decided to scoot through. He was not expecting me to stop so suddenly and rear-ended my car leaving both of us stopped on the tracks with a train coming! We were both able to restart the cars and moved off the tracks in time but it was quite scary and obviously dangerous. Thankfully the collision was at 20 mph so the damage did not disable either car or cause any injuries that would inhibit us from moving to safety.