Air Travel – Why do airlines usually ask you how much you have purchased?

It's been a while since I was on a plane, so I'll try to remember it.

I live in Canada. Occasionally, when I fly back from the USA to Canada, the airline (Air Canada, United Airlines) gives each passenger a "leaf" to fill in before we land.

I am not sure what this leaf is, but it usually asks for your name, where you are traveling and how much money you have spent in the country.

I want to know two things.

First, what is this piece of paper and is it always handed out? Is filling in optional?

Second, why do you need to know how much money we have spent in another country? For example, if I bought a gift in the US ($ 400) and return to Canada, do I have to pay taxes on it?