Doing so means more money for the dealership and often a bigger commission for the agent as well. Fortunately, the right approach can reduce your risk of getting ripped off.
Before you visit a car dealership, it's smart to know what you are looking for, personally. This is in terms of your need for the vehicle, how much you want to pay, and how you'll be paying (financing, cash, etc). However, that doesn't mean you want to share that information with the agent.
If a car salesperson asks whether you'll be paying in cash or financing, for example, it's best to be a bit vague and simply say something like “not sure yet.” You also don't want to let them know your maximum budget, because they'll try to get you to spend as much as you can, if not a bit more.
Car salespeople will also try to uncover if there's any other decision-maker. If you're relying on a spouse's credit to make the purchase, for example, they'll try to figure that out. Ultimately, it's to play everything close to the vest as they'll have less to pressure you with.