The audience is desensitized to just loaded guns pointing at other people. After all in Hollywood a lot of dialogue goes on while someone is pointing a gun at someone else. That is the time for a lot of plot to be explored.
So to ratchet up the suspense and make shooting seem even more imminent, without actually shooting, they include the cocking noise. When in reality just the pointing of the loaded weapon should be enough to reach that level, but is not because of the above reason.
You similarly see a lot of movies and shows with the guy racking the slide on an auto or charging the bolt on a long gun or pumping a pump gun just prior to shooting or dialogue. As if people run around in dangerous situations engaging people who pose a lethal threat, and then just decide at the last moment to chamber a round. They always have just the perfect situation that gives them the time to do so as well.
It is unrealistic, but it adds a perceived increased level of seriousness. Because the audience is accustomed to everyone running around with guns by that point, so just the presence of the gun and it being pointed is not serious enough anymore to get a reaction.
Instead they increase the suspense and announce that something serious might actually happen, because someone finally chambered their weapon!
Hollywood is entertainment, and entertaining the masses is often about taking people on an emotional rollercoaster, not sticking with reality.
Anyone in almost any profession portrayed in something made by Hollywood can tell you how many things they got wrong, procedures that were ignored, or details that were far removed from reality. Yet is expected to go unnoticed by the typical audience member. It is not about facts or reality, but rather meeting a perceived reality while emotionally engaging the target audience.