The answer is that we don't know for sure. All we know is that at some point in the process of developing the vaccine, what was thought to be cowpox, was not in fact cowpox, but was rather what we now know as Vaccinia virus.
Part of the problem here is that the vaccine process was not entirely scientific in its development, there were multiple sources from multiple locations around the world developed more or less independently using an inoculation process (by Jenner's method, just copied). In many cases, before the development of heat-stable vaccines the method of carrying the vaccine to other parts of the world was to transport a live animal infected with a pox virus (I don't have evidence for this, but it is mentioned in "The greatest killer: smallpox in history" by D Hopkins 2002.
The history, as I mentioned is murky. As Baxby wrote in 1977:
Smallpox vaccination was established long before the nature of viruses was known and therefore very little is known about the number of poxviruses circulating in the 18th and 19th centuries.
and as Razzell 1999 also noted:
The main English vaccine (the Lister strain) was sent from Cologne some time after 1871 and is reported to have been taken from a Prussian soldier suffering from smallpox... ... Many of the English vaccines in the 1850s were derived from the inoculation of cows with smallpox and as Baxby has pointed out the most recent evidence suggests it is not possible to produce vaccinia through the variolation of cows.
In addition, Schrick et al (2017) sequenced a 1902 vial of vaccinia vaccine, finding that it clustered with horsepox, noting that Jenner also suspected as much in his 1800 publication, several sections being devoted to the similarity between horsepox and cowpox and the transmissibility between the two such as the below:
In the month of November 1797 my horse had diseased heels which was certainly what is termed the grease and at a short subsequent period my cow was also affected with what a neighbouring farmer who was conversant with the camplaints... ... No other person milked the cow but the lad above mentioned I am firmly of opinion that the disease in the heels of the horse which was a virulent grease was the origin of the servants and the cow's malady
In conclusion: we don't know, but it seems likely that somewhere along the way a horsepox was used and with repeated passaging either in animals or in people, the virus developed into vaccinia as we know it now.