Cheese seizes when the proteins decide they would rather stick to each other than spread out and melt into their surroundings. There are a couple things that encourage seizing, including having the cheese clumped up closely together so it's easier for them to tangle, or having too much liquid between clumps of cheese so they don't spread out well, or having the temperature too high (overcooking). In short, the more uneven the texture, the more likely clumping will occur, and the more clumping, the more likely seizing will occur - this is a general principle in cooking, it is easier to mix things the more similar they are, and clumping and such is more likely the more different their textures are.
So, how to prevent it? You need to equalize the texture as much as possible - either thin out your cheese, or thicken what you're melting it into, so the proteins will not clump together but spread out into a melty puddle. To thin your cheese, you can grate or shred, or slice or chop your cheese finely, this exposes more surface area to the surrounding liquid and encourages a more even texture.
You can also moisten the cheese, that helps a lot. If you're melting cheese straight or mostly so, like cheese toast or a decorative sprinkle on top of something, simply sprinkling or spreading water on top will give a bit of encouragement for the cheese to melt instead of dry out. If you're melting a drier, sharper cheese, you can grate or shred it, and let it sit in water for a while to hydrate. These cheeses dry out as they age, so reintroducing some water into them encourages them to melt like younger, moister cheeses - especially if you give enough time for the water to soak in properly.
The second option was to thicken whatever you're melting the cheese into. The classic recipe for cheese sauce starts with a roux for that reason, and adds cheese slowly, because the more stuff floating around in the sauce, the more chances the cheese will grab and mix into the stuff floating around in the sauce, instead of itself. Melted cheese will itself thicken the liquid, so you really just need a bit of something to start - I've used things like gravy mix or powdered cheese sauce or starch to thicken, among other things. It doesn't even have to add a lot of flavor if I just use enough to get started, the amount of cheese outweighs the single spoonful of thickener. Extra liquid should be added closer to the end, when the cheese has already melted into your thick sauce - its easier to make a thick sauce thinner than melt solid stuff int thin liquid.
You can, of course, use emulsifiers like mustard, egg yolk, cream. I tend to think of and use them as thickeners, but there may be benefit out of proportion to amount if you want to minimize the other flavors.
Other notes - overcooking encourages the cheese to seize up, so heat gently and as evenly as possible while the cheese is melting. It can take higher heat after everything is well mixed, if you want to brown the top or anything. Also, remember to stir frequently - some of the clumping or unevenness is simply physical, mixing encourages the melty edges of the cheese to spread out and mix into their surroundings and slowly spreads through and thickens the surrounding liquid. The larger bits of cheese will melt better once they get up to temperature, since the liquid is a bit thicker and they are a bit more exposed to moisture.