It's not required, but will probably make your life and SEO a bit better, plus it takes very little to do it–see @VincePettit's answer–so isn't really worth fighting.
[M]y thinking is search engines should be smart enough to understand that and should consider it as one page not as duplicate.
That's an opinion. The reality is that www.example.com and example.com only show the same content because you've told them to and it's basically standard practice. This isn't a failing on the search engines' part; the two URLs are actually separate things. If you poke around in your DNS settings, you can delete the www
sub-domain so that it doesn't work at all, for example. There's also nothing stopping you from putting up entirely unrelated web sites at the two addresses. (Obviously that's probably not a great idea, but we're talking technical details here, not practicality. For an unrelated but similarly low-level sort of question, see this prior thread. You might also find What does WWW do? interesting.)
So, the fact that you happen to have exactly the same thing at both of those locations right now is basically meaningless. (Again, at the technical level.) Overall, it's better and easier for everyone all around if you take the time to specify which is canonical, by redirecting or whatever, than expecting the engines to constantly index both(or more) versions and then compare them on their end to make sure they're still identical from the last time they were looked at.
For example in Google webmaster tools we can set the preferred domain name.
That's nice for Google. Now go around and do it for every other search engine, assuming they offer you the ability to. Or wouldn't it again be easier if you just do it on your end before they become confused about it in the first place?