You can take your pet on some trains, but the rules for this vary depending on the country you travel in and the type of train you take. On some trains, you can take small animals in cages/boxes for free.
However, sometimes you’ll have to buy a special pet ticket, before you can bring your furry friend on the train with you. Special provisions may apply to helper/service dogs.
Detailed and first-hand information about pet transportation can be found on the websites of the national railway companies. Here you can find the websites of the national railway companies of each country.