Tap 3 identical hats to remove them, and keep playing until you clear the whole board to unlock the next level.
On mobile or tablet: Tap 3 identical hats. On PC: Click 3 identical hats.