On the Vancouver to Seattle train (the train goes beyond Seattle but not totally sure where to), go through US customs/immigration in Vancouver before getting on the train (I guess like you do in airports). Going the other way, I think we did it on arrival in Vancouver though I could be remembering wrong (Vancouver is the only stop in Canada).Years and years ago when I took The Montrealer (Montreal to DC, no longer exists) customs came right on the train. Now they make you collect all your belongings and line up inside - customs - wait a decent amount of time and back on the train.
Since I was taking such a short trip on the Maple Leaf, on the way back I simply got myself to the Rainbow Bridge & walked into Canada. Seemed so much easier, believe it or not.
I believe Amtrak pairs with Via for Montreal, Toronto & Vancouver. The price is ridiculous due to Via rail, not Amtrak.
On the bus, we got out at the border, went through customs/immigration and got back on the bus (I've only done the bus from Seattle to Vancouver, not the other way).