Of course our thoughts must be "accidents" in that they are not completely controlled by any conscious entity (and only partially controlled by ourselves). If that were not so we would be puppets, thinking only that which was decreed for us.
Evolutionary theory does not say that our thoughts are mere accidents in any wider sense. Our thoughts are shaped by our brains, which are themselves shaped by evolution to be effective at producing useful thoughts.