Puck changes Bottom's head into that of an "ass" or a donkey head. Puck does this as a prank because he enjoys playing tricks on mortals and fairies alike. The transformation is appropriate because Bottom's name is synonymous with "ass" and also because Bottom's personality is stubborn and pushy. We see this when Bottom is attempting to take all the good parts of the play he and his acting group are preparing for Hippolyta's and Theseus' wedding feast.
When Bottom wakens Titania with his braying, she falls instantly in love with him. This is a result of a spell placed on her by Oberon, the King of the Pixies. Oberon puts this spell on Titania because they have had a disagreement, and he wishes to get revenge by making her fall in the love with the first thing she sees upon waking. Her love affair is good for a few laughs, and then he removes the spell as she recounts the "dream" she had.