We have no way to know if the gospel writers knew they were lying, because we don't even know who they were.
It is my understanding that the earliest examples of their writings are fragments of copies that were made decades (centuries?) after the originals had been created. In other words, we probably don't even have the earliest copies of copies of their work, much less the originals.
It seems more likely that they wrote --and embellished-- stories they heard from others who claimed to have been there. We have no way to know if they paid for this with their lives or how they might have reacted if any pressure had been placed on them to recant. There are four gospels in the Bible, but a great many were written around that time. I don't get the impression that these writers were concerned that they might face dire consequences from producing them.
So, my guess would be that they either were not concerned that they would be executed for writing these texts, or they sincerely believed in something that they had not experienced. I'm inclined to believe the former, but the latter is not unheard of.