Europe is a continent; the United Kingdom is a sovereign country. The UK is located off the northwestern coast of mainland Europe, comprising Great Britain (England, Scotland, Wales) and Northern Ireland.
The UK was a member of the European Union (1973–2020) but never "part of Europe" in a territorial sense—it has always been geographically adjacent. Post-Brexit, it is a third country relative to the EU, but remains culturally, historically, and economically intertwined with the continent.
Think of it like Japan and Asia: Japan is in Asia, but not part of any other Asian country. The UK is in Europe (geographically), but not part of Europe as a political entity.