When you flatter someone, you praise and compliment him or her — but you aren't totally sincere. You flatter your friend by telling her she's the best driver in the world. Because you want her to offer you a ride.
The Old French flater originally meant "to stroke or caress," which is what you do to people's egos when you flatter them. When you flatter, you probably want something — it could be as simple as wanting someone to like you. That's why people who meet celebrities tell them they're the greatest. More positively, if your hairstyle flatters your face, it emphasizes your best features.