Malapropisms and puns are similar in that they both replace a word with a similar-sounding word. However, they differ in their nature and effect.
A malapropism is an unintentional language error that typically has a humorous result (e.g., mixing up “amphibious” and “ambidextrous”). Malapropisms are generally mistakes, but they can sometimes be used for comedic effect (e.g., when a writer intentionally creates a character who accidentally uses malapropisms).
On the other hand, a pun is a deliberate play on words. Puns usually exploit similar-sounding words and double meaning to generate laughs, show wit, or create irony.
In other words, a malapropism occurs by mistake and results in a nonsensical or funny statement that the speaker never intended, whereas a pun is intentional and is used for comedic or rhetorical purposes.