One meaning of quarters is a lodging or where one is stationed. From that, one possible explanation for the phrase "give no quarter" is that no lodging will be provided to the enemy (as in no prisoners will be taken).
The "beat to quarters" phrase is based on the meaning of quarters as one's station. It is a naval term which is a call for the crew to go to battle stations.The modern US navy still uses the phrase "general quarters" (as does Star Trek). The British use the term "action stations" I think.