You may cancel the tickets, but there are rules which apply to each ticket (so you won’t get a 100% refund). Also, most of the tickets are non-refundable if cancelled. Only a handful of airlines waive the penalty in case of visa being rejected (and you need to provide the paperwork to support that).
We recommend travelers to look up visa requirements before they book a trip. We are aware that many countries require travelers to have already bought a plane ticket to enter and exit the country before they submit the visa application.