From what I understand in the medieval era most farmers practiced subsistence farming and were part of something like a gift economy within their own villages which was the main method by which they obtained resources they couldn't make themselves. But by the industrial era most practiced commercial farming instead and were well integrated within the market-economy.
My question is why and how did this happen; and when did this process start occurring?
Well, the short answer to your question would be that the British isles experienced an agricultural revolution in the 18th century, which drove up crop yields significantly. New crops, technology, and ideas allowed landowners to exploit their lands with greater efficiency. According to the traditional narrative, this agricultural revolution was a necessary precondition for the industrial revolution because it allowed for a population surge and decreased agricultural labor requirements, which created a mass of laborers in urban centers.
Buuuuuuuuut, I want to interrogate the premise of your question. Because, while agriculturalists across Western Europe slowly and irregularly adopted agricultural technologies that increased crop yields, the idea that there was a “subsistence” economy is false. As Horden and Purcell point out in The Corrupting Sea, shooting for subsistence inevitably will lead to failure. Agriculturalists were, without doubt, seeking for a surplus that could be sold for some sort of profit. The idea that the medieval village existed in a state of “primitive communism” that was disrupted by the development and spread of capitalism is a misreading of the past often perpetrated by historians of modernity.
Even if we proceed from logic without evidence (though I shall supply that as well), we can see a major problem with the assumption that medieval agriculturalists were subsistence producers: how did people in cities eat? The answer is cities served as local markets where agriculturalists could sell their surpluses, and international grain markets existed in Europe. Anecdotally from my own research, we can see an example of this in Genoese accounts of the 14th century unrest in the city, when agriculturalists from the countryside joined in protest of changing requirements for the sale of their produce in the city.
We also know that grain merchants possessed a sophisticated understanding of regional/continental grain markets. As Kathryn Reyerson has shown in her article about the grain market of southern france, grain merchants imported grain in lean years and exported it in years of plenty, and they would also buy up grain in these lean years to drive up prices. And these grain merchants were often incredibly wealthy. The great banking families of Florence gained most of their wealth through the trade of bulk commodities, not their services as financiers. The best work on the grain trade can be found in the scholarship of David Abulafia.
But you were asking about northern Europe, and England specifically. England was part of a North Sea grain market. Nils Hybel has an excellent article on this topic. Here, he comes to the same conclusion as Reyerson does about southern France. The region sought to explore grain, usually from the eastern port of Hull, whenever possible, but it would seek imports during lean years from continental sources, specifically cities of the Hanseatic League that could import grain, usually rye, from the Baltic regions.