Each time A touches the ball is a spot of illegal touching (a violation). So you're going to give the best spot (for B). And with respect to the goal line, only the ball matters (not the feet like the NFL). So, in both cases, it'll go to the B5.
Unfortunately I don't see any ARs in 6-3-2 that cover this... just the actual rule 6-3-2-a "No inbounds player of the kicking team shall touch a scrimmage kick that has crossed the neutral zone before it touches an opponent This is illegal touching, a violation that, when the ball becomes dead, gives the receiving team the privilege of taking the ball at the spot of the violation". Ultimately, you can have multiple violations on the same play.