<<What do you mean by "produce" then?>>
Well, you certainly raise some interesting questions about GDP. Anyone who produces 40% of the gross domestic product produces 40 % of the total value of all goods and services produced in the country in a year. So "produce" means the production of goods or services.
Someone once pointed out that if an oil tanker spills a billion gals. of oil and it costs $50 billion to clean up the mess, then that $50 billion is counted in the GDP just the same as if it were $50 billion worth of ball bearings or $50 billion worth of brain surgery or lawnmowers or anything else more productive than cleaning up after a mess. So that GDP can be a pretty rough measure of a country's productivity or standard of living.
If a government produces 40% of GDP, that production would take the form of market value of government services (mostly) plus whatever the government manufactures - - so it's output as regulatory services, metrics (like the national census,) social services (ensuring the flow of funds to the underprivileged, the unemployed, the disabled,) education, research, policing etc. In a socialist state, more of the GDP is government output (and taxpayer funded) and in a less socialist state, more of the GDP is privately produced and (to the huge, often obscene, profit of the producers) consumer-funded.
The consumers, unlike the taxpayers, have very little oversight over their providers, and so can expect to get regularly fucked in the ass by them, as in fact has occurred with clockwork regularity in your own country and continues as we speak. To add insult to injury, when, as happens more often than not in capitalist countries, the capitalist owners also manage to "own" not only the means of production but the "government" as well, they not only get to fuck the consumers up the ass on a regular basis, but to add insult to injury, can actually expect the taxpayers to bail them out whenever they run their "businesses" into the ground.