I am a Canadian citizen and have been in the US for almost 2 years. If I cross the border by car, would Canada have that information? Would they know I have been gone for 2 years?
You're a Canadian citizen. You have unlimited right to abode in Canada, or not. So Canada does not care if you stayed 2 years in the US or spent a string of 90-day hops to South America, Africa, EU, Dubai, Japan, Australia and back again.
However, it may complicate your ability to re-enter the US. You are only allowed 6 months in the US, and you have overstayed.
The US does not have exit controls, and does not know that you didn't enter Mexico 5 months and 28 days after entering the US, but the US does interchange data with trusted nations, and will know that you didn't reenter Canada (or fly anywhere). So they may refuse you a re-entry to the US without proof that you didn't overstay.
This may also have interesting effects on your health insurance and taxes.
It depends on how you traveled to the US. The US and Canada exchange information about people crossing the land border so that the entry record in one country can be used to create an exit record in the other. However, US and Canadian citizens are excluded. I remember having read that the system would expand at some point to include them, but I don't think this has happened yet, let alone two years ago.
If you flew, however, Canada probably created an exit record from the airline's passenger manifest (I don't know the details, so I could be wrong about that; it's possible for example that Canadian citizens are also excluded from such systems).