If you meet the requirements for entry into the USA under the Visa Waiver Program (e.g. you've never been arrested or convicted of a criminal offence) you simply need to fill in form I-94W and pay US$6: http://www.usembassy.org.uk/cons_new/visa/niv/ vwp.html
If you don't meet the requirements for travel under the Visa Waiver Program (and you don't want to simply lie to get in - which is probably what most people do), you need to apply for a visa: http://www.usembassy.org.uk/cons_new/visa/niv/ index.html
You clear US immigration in Vancouver before departure - the train is kept in a locked shed until ready to depart. Customs come on the train at the border and travel to the next stop, checking you on the way.
A very nice journey - particularly in summer when it's light enough to see most of the way. About 4 hours from memory