Badges are assigned when certain landmarks are reached in an activity.
For example, an activity might have a badge on offer for reading through most, or all of the content. There might be a badge for passing a test, or watching a video or completing a game.
Different activities offer different badges, and there might even be hidden ones.
The activity moderator can combine badges to make an award. This will most likely be in the form of a certificate.
You can view a list of your badges on your progress page (example shown below)