GPs can be either salary doctors or 'partners'. Salary doctors are a recent thing, it used to be only partners. Partners own a stake in the business. So if there are four partners, they get their salary from taking a quarter of the profit the practice makes at the end of the year. Salary doctors are paid a fixed salary out of the budget the practice receives. They're generally more likely to work part time than partners.
A GP has certain outgoings such as money spent on staff costs, drugs on site, equipment, etc. They get an income from the NHS. This income will exceed the expenditure and be divided amongst the partners at the end of the year, which they get paid as a salary over a year. However, this salary can change year on year because of the reasons I outlined above.
In rural practices, you get pharmacies on site. In urban practices, you don't. Therefore rural practices have a greater income (to pay for drugs) and a greater outgoing (money spent on drugs). So in theory, if a practice requested money for more drugs than they needed, the partners could make some money out of it. This probably happens to a small extent unintentionally, but I don't think massive fiddlings would go unnoticed, this isn't a corrupt country.
GPs don't 'work for' the NHS. When Aneurin Bevan was trying to convince the GPs of his new and radical National Health Service scheme in 1948, he had to compromise by respecting GPs' independence. So GPs are contracted to a surgery and manage the finances themselves, they don't get paid a top-down salary by the NHS.