It was a revenge killing founded on a deep personal betrayal
The details of Haydon's death are subtly different in the various adaptations of the Novel (which strongly hints but never explicitly confirms that it was Prideaux's work). But the motivation is clear in all versions.
Prideaux and Haydon were close friends from their university days. They remained close while working for the Circus. There are even hints of a homerotic connection between them (and we know that Haydon was bisexual).
For most of the time during the events in the story we have no idea who the mole is. Significantly, when Control attempts his risky scheme to acquire information from a supposed eastern European mole (details of exactly which country differ in different adaptations), Prideaux tell Haydon before the event despite Control's orders. Whether this makes the trap any worse is unlikely (as it was a Karla plot all along) but it shows that Prideaux has complete trust in Haydon.
When Prideaux is shot and captured, Haydon is instrumental in having him released/rescued. He may have felt particularly guilty that his friend suffered from his betrayal. But this hardly compensates for the fact that his betrayal cost Prideaux injury and torture (and probably death to his network of spies).
So, when the truth of Haydon the mole is revealed, Prideaux is strongly motivated to take revenge.
How was Prideaux able to commit the act? We know that security was lax at the detention centre (Smiley specifically remarks on this in at least one version of the story). The sniper rifle is a tool that Prideaux is familiar and expert with (we certainly know he is good with guns and is a trained spy). And it makes a particularly visual cinematic statement that simplifies the task of the killing (other versions of the story have different means of death but they would require more explanation and time which would work less well in the constraints of a movie). The move hints that Haydon sees Prideaux just before the shooting and further hints that he accepts his fate. Perhaps he sees the act of revenge as justified given his own deep betrayal that deeply hurt his friend.
Whatever the situation, Prideaux's motivation is clear.