Union Query format in mysql
First problem is that you "override the LEFT join by using the WHERE clause referencing that table, so no "NULL" row can show in the results.

Second problem is that you are using an aggregate (count()) but you forgot to add a proper GROUP BY.

Fixing these the query looks like this:

SELECT class, count(ship) as sunks
FROM (
  ( 
   SELECT classes.class, outcomes.ship
   FROM classes
   LEFT JOIN outcomes ON classes.class=outcomes.ship AND outcomes.result='sunk'
  )
  UNION
  (
   SELECT ships.class, outcomes.ship
   FROM ships
   LEFT JOIN outcomes ON ships.name=outcomes.ship AND outcomes.result='sunk'
  )
) AS tmp
GROUP BY class


There is a fiddle based on your script to see it in action http://sqlfiddle.com/#!9/4840f6/8