As always, it is about the location of the ball related to the plane of the goal line, when it becomes dead.
The ball becomes dead the moment that A88 "possesses" the ball, which means he is holding/controlling the ball firmly with his hands/arms while touching the ground inbounds.
In both examples, if you envision A88 as having grasp/control of the ball in the field of play, but the ball is over/beyond the goal line when he first touches the ground in the end zone, that would clearly put the ball in the end zone, thus, touchback.
In example B, if you envision the possibility of A88 having grasp/control of the ball outside the goal line when a foot first lands on the ground inbounds (field of play or end zone), then, technically, that would be B's ball at the spot of the illegal possession. However, philosophically, anytime there is question regarding the location of the ball in such cases, we are to put the ball in the end zone, and make it a touchback.