OK---so same play and Team A touches the ball then commits the foul of illegal kicking?
Team B can accept the penalty during the kick play either from the previous spot or from where the dead ball belongs to team B. The kick went out of bounds at the B-10 so it indeed belongs to Team B there. B could choose to take the ball, 1/10 at the B-20. If they choose to enforce from the previous spot instead, the penalty does not include loss of down because the illegal kicking was of a scrimmage kick beyond the neutral zone. So, ten yards, repeat fourth down.
Team B cannot, however, enforce the penalty from the spot(s) of A's illegal touching.