On board and inflight is one of the safest indoor environments from a Covid-19 transmission perspective. But that doesn’t mean that travel is safe. Most planes (but not smaller regional jets and turboprops) have HEPA air filtration that’s highly protective.
That doesn’t mean the virus doesn’t spread. Often when this and other viruses are attributed to flights it’s likely spreading at airport security, in the gate area, or on the jet bridge. These are places where passengers congregate closely together and where the air isn’t filtered as well.