You are mistaken here. Physically destroying a gun or machine gun, and killing and suppressing the crew are two different things. Destroying it was as hard as you claim, those things are made of robust metal and need an almost direct hit to be destroyed, and they are tiny targets. But suppressing and/or killing the crew takes a lot less fire. An artillery shell will kill a man at many times the distance it will destroy a robust metal machine. Of course in an ideal world you would also destroy the weapon, or given a breather, the enemy will find replacements or drag the surviving crew out of cover.
There are plenty of examples of infantry defences defeating armoured assaults.