What is the difference between 型 and 形? I was taught that 型 means something like "form" and 形 means shape/form、and I wonder, are they interchangeable? Does 型 only come after a word or phrase?
By definition, 型 means die, matrix, model, mold, or a tool to cast something into a certain shape. 形 means, as you said, form, figure, shape or the overall outline an object has. And naturally, 型 has an extended meaning just like that of English model (or type, pattern etc.) which stand for discrete classification of objects by certain criteria, as if they share the same original caster.
They have same pronunciation as suffixes (both kun'yomi: がた and on'yomi: けい), but whenever you see ○○型, you should expect the literal translation ○○-type, while ○○形 is ○○-shaped. This is the basic idea. Of course some "types" are based on nothing more than visual appearances, in which case 型 and 形 are interchangeable, but not always. Also note that 形 can be used as a suffix only when you mention the physical shape.
地球型惑星 terrestrial planet (whose composition is like the Earth; all planets have the same round silhouette shape-wise)
夜型人間 night owl (who has nocturnal trait; nobody looks like the night)
楔形文字 cuneiform (whose shape is like wedges; they are otherwise not related to wedges)
円形脱毛症 alopecia areata (or spot baldness: whose shape is more or less round)