Maybe it feels counter-intuitive to some that sharks were there before trees...
But I hope it is intuitive that there was water long before there was soil? Then it's just a small step to realize life in water has had a much longer time to develop.
Mosses were likely already there though