The obvious difference between your experiences and the person you're replying to is that he's residing there and you're visiting. You're right that your rights are far more limited when you're a visitor to a country crossing a border, but he and this thread are talking about what rights residents to a country have regarding the border.
Asking why someone is visiting is also pertinent to the border agent's direct job, because different types of visits require different documents, such as a work visa.