Ambulances have been waiting nearly two hours on average to hand over patients outside Welsh hospitals, new figures reveal.