Well, there are two major reasons why they do this. For one movies tend to be self contained as opposed to ongoing works, they are going to do two, or maybe three movies if they get lucky (or so they figure) and having a "Secret Identity" discovered is a quick dramatic scene they can pad out a movie with. Furthermore one of the big problems with Super Hero movies is that the directors and actors always want to show the character's face, it makes expression easier, and of course actors want exposure. If they aren't barefacing themselves, they are just some guy in a fancy costume, or basically voicing a CGI cartoon character for the most part. This is a big part of why I do not think Marvel's current "Cinematic Universe" will be the last word on super heroes or the specific characters, even if it will do quite well. There is still a lot of room to do them again later and be more true to the comic books.
Marvel's movies had the advantage of bringing everyone more or less into SHIELD pretty quickly, with a hook being present in most of the movies. One of the big reasons for concealing your identity as a super hero is to avoid accountability, basically your running around committing criminal trespassing, breaking and entering, assault and battery, and all kinds of other crimes in order to act as a vigilante. When you fight a super villain there is tons of collateral damage, and in general your typical person isn't going to be happy over having his car smashed up or used as a missile weapon by some super hero, even if the hero is saving lives. "The Incredibles" sort of made this point, and demonstrated a big part of why a lot of heroes are going to act as independent "costumed adventurers". Furthermore a big part of a lot of Super Heroes is that they are hated by the authorities, and perhaps even the public at large. The distinction between hero and villain that exists for a comic reader doesn't necessarily apply to the world comic book characters live in. Indeed one of the things that made "The Avengers" fairly unique after a while is because the issue of government oversight, collateral damage, and similar things became an issue and got in the way of them doing their job, especially when the government assigned them idiots as handlers. "The Fantastic Four" has run into countless problems, legally and otherwise, over the years due to having public identities and the fact that pretty much everyone knows where they can be found (The Baxter Building), in the comics they themselves have expressed remorse over not having had the forethought to adopt secret identities.
One thing to also consider is that in most comic book universes there are a lot of heroes and villains, which is part of why it's not easy to find who your looking for. For example in DC comics, a lot of people think it would be easy to deduce Bruce Wayne is Batman or Oliver Quinn is Green Arrow based on only a few people having those resources. They forget about all the other groups out there that have loads of money and produce super-gadgets and the like (thugs with ray guns aren't all that uncommon), heck both of these dudes fight rich dudes (with criminal money or otherwise) with their own gimmicks as a matter of course. In Marvel, watch Professor X use "Cerebero" at some point and notice how many bloody mutants there are supposed to be, most are just minding their own business. Finding the one dude your looking for isn't easy, and that's part of the reason why things like "Project Wideawake" got green lit and a shotgun approach to taking down all mutants (at least potentially), and even had Iron Man involved (I believe he was one of the geniuses that helped develop The Sentinels). I mean people tend to forget that in comic books it's a legitimate concern that some dude can walk down the street and level a couple of blocks, and then basically disappear, and it's not like you can just pick that one dude out easily because he has powers or some kind of odd feature. A point inherent in "The Civil War" before it went off the rails for RL political commentary as well. The point here being that you put on that mask and your not going to be easy to find, so nobody is going to show up to arrest you, or take you to court for massive property damage, and in Marvel as much as certain people might want to, they can't exactly go around and round up every mutant in say New York City every time two dudes in spandex fight it out in Times Square.
Secret Identities make a lot of sense, but are counter productive to what movies want to achieve, and the promotion of the actors playing them.
As far as close associates not being able to figure out who certain super heroes are, there have been mixed answers to that over the years, a lot of them character specific. For example few people (even those who know him) suspect Matt Murdock because he's blind, causing them to sometimes overlook the obvious because of it. In Superman's case it was at one point explained that he used "super hypnosis" so basically it became impossible for people to make, or maintain, the connection (this was dropped, but for a while I believe it was canon... Superdickery mentions it I believe). More "recently" I seem to remember a comic where members of The Justice League were discussing their secret identities and it was mentioned (by Batman I believe) that when Superman transforms into Clark Kent, he also changes his voice by an octave and slouches to make himself look shorter, and other things. You'd be surprised how effective a tactic something like that can be, although it doesn't really explain it when it comes to close associates who have spent a decent amount of time with both identities.... at the end of the day though, some secret identities are better than others, Superman kind of stands out for it being kind of dumb due to the lack of a mask, and how is has literally been portrayed as him simply changing clothes and putting on a pair of glasses... though to be fair the image of Clark Kent taking off his glasses and jacket, revealing the "S" on his supersuit as he prepares to save the day has become both iconic and strangely awesome at the same time.