Forgive me if this has been asked before.

I'm a Canadian who is based in Canada.
When I enter the US, they stamp a B1/B2 stamp and Canadians get up to 6 months to stay, which
I've never done.

But this time when I entered, I was questioned for 2 hrs and was stamped a B2 with 5 weeks to stay.
Apparently I came to visit in Jan. for 10 days vacation, and this time they are worried I'll stay forever,
though i told them I have no such intention. (no healthcare in US)

I have no intention to stay in US but just want to stay one more week, that's it.
My question is, how do they know the date I leave the US? There is no US immigration when I leave US to return to Canada. And Canadian immigration doesn't tell the US which date I left. In fact, I don't even have that form when other foreigners fill out when they enter US.

I don't think the airline's database is connected to US immigration, is it?
It it were, they would know your travel schedule right away from the point you enter US.

I won't risk it but just wondering how this whole thing works.

Thank you very much!