Wikipedia has an excellent piece on this, but the basic gist is these are a military tradition practiced in the Commonwealth countries (e.g., United Kingdom, Australia, Canada, New Zealand and India) These are granted only through the British monarch's Royal Authority. They are an official acknowledgment of a military unit's achievements in specific battles.
Not every battle fought results in a battle honour. A Unit can receive more than one battle honour over the course of a larger operation (Wikipedia cites the Scots Guards receiving honours for "Tumbledown Mountain" and one for the overall conflict "Falkland Islands 1982"). The unit need not have defeated the enemy to receive a battle honour (e.g., the Hong Kong Volunteer Defence Corps was awarded the battle honour "Hong Kong" for its actions even though it was unable to stop the invading Japanese army from capturing Hong Kong in 1941)