The changing table is a difficult situation for many mothers — you're trying to keep baby safe, but he keeps wiggling away. At five months, baby can't understand the concept of safety... or even a dirty diaper! Most likely, baby was happily playing somewhere when he was scooped up for the diaper change, which understandably led him to be startled and upset. At this age, it helps to explain to him what you are doing before you change the diaper in order to introduce the transition, even though he may not fully comprehend what you are saying until many months later. This diaper change struggle can continue well into toddlerhood, so it's helpful to start a routine of verbalizing what's going on right now. Once he can understand you, it'll be easier for him to settle down during diaper time.
To prepare him for what is going to happen next, you can say, "I know you are enjoying playtime, but Mommy needs to change your diaper now." While you're changing him, offer various distractions like a mirror to look at, keys to hold or a picture to focus on — as you've seen, it can be very hard for young babies to sit still for a diaper change, but distractions are helpful.