Usually, when you cross for the first time, you are asked to go into secondary security and obtain an I-94 form (card). They will staple it into your passport. Do not remove it!
Form I-94, is the Arrival-Departure Record Card, it is a form used by U.S. Customs and Border Protection (CBP) and intended to keep track of the arrival and departure to/from the United States of people who are not United States citizens or lawful permanent residents.
The I-94 card is date stamped and valid for 6 months. It also has a fee of $6.
Prior to the 6 month expiry of the I-94 you need to either return it to US Customs at a border crossing or leave it with the Canadian border guard when you return if you know you will not be crossing prior to its expiry. Failing to do so will result in a stern lecture from the US Border Guards the next time you cross with an expired card, an experience I try to avoid.
After 6 months you need to go through the process again and pay another $6.
Usually when you have a valid (unexpired I-94) you will simply cross like everyone else after answering the usual questions at the kiosk.
However, I have also been allowed entry without a valid I-94 and I simply think the border guard at the kiosk didn't realise he needed to have me do so. Trust me, it is not normal as they are very vigilant in collecting that $6.
He's a tip. If you know you will be needing to get a new I-94, cross by yourself. The reason I do that is because when you get taken into secondary screening to obtain your I-94, EVERYONE travelling with you is required to go into secondary as well. So, If I know I am travelling with a group, I will cross a day or two in advance, get the I-94 and get gas or groceries and cross back. Then when I cross with the group, I simply show waiver and my passport (with I-94 stapled inside), answer the questions and we all cross as normal.
I hope this helps.