Because so far Bomber Command has not been able to sink the damn ships despite devoting a significant amount of effort to that mission. Carrier aircraft have the equipment and training to hit precise point targets while Bomber Command is quite happy to bomb the right county much less the right block in the right town.
Not "carrier aircraft",
dive bombers. Which can operate from land bases just as effectively as from carriers - more effectively, really, since a land base can operate planes by night, or in much worse weather than a carrier, and poses far less risk of take-off and landing accidents. And has much better accommodations for air crew and erks, more room for aircraft, fuel, and munitions, and better repair and maintenance facilities. (Ships are
cramped.)
Carriers also operate torpedo bombers. As it happens, Coastal Command had lots of land-based torpedo bombers. AFAIK, they rarely or never employed them in attacks on ships in French harbors. Because torpedo plane attacks on ships in harbor could be effective only against weakly defended targets or with complete surprise. When there was heavy flak and torpedo nets, torpedo planes were useless. When the USN annihilated the remnants of the Japanese Navy in harbor in July 1945, only DBs attacked.
Oh, and Bomber Command's difficulties in hitting
Scharnhorst and
Gneisenau might have had something to do with intense flak, heavy fighter opposition, and the blanket of dense black smoke the Germans deployed whenever the RAF attacked. I think dive bombers
might be somewhat affected by all that.