The rest is history podcast have a three parter on the battle of Trafalgar, they cover a lot of the lead up and essentially it sounds like the Royal Navy professionalised in a way that the the French and Spanish didn’t. Portsmouth was very industrialised to constantly develop and churn out naval assets and improvements. Coupled with the kings use of new financial methods and that 25% of the country’s GDP was spent on the navy you had basically an unbeatable force by the time Trafalgar happened.
It was well-known during that period that French shipwrights could built better ships - the problem was that the Royal Navy had better seamanship and would win most naval actions, and commandeer the better-built french ships and integrate them into the Royal Navy. So the british had the advantage of their own ships, and many of the better-built french ships.