He was probably breathing heavily because he had just eaten and you were staring at him. Feeding time in general is a very vulnerable time for them. If they see a giant heat source coming toward them, they will be a little bit scared!
Just leave him be, check on him once a day or so. He should be fine.
The substrate ingestion is not a problem. I have never heard of a ball python becoming impacted from eating substrate.
Also, the yawning you witnessed was the snake realigning its jaws. Completely normal.