A: Article 15 - Player in the Act of Shooting in the rulebook states:
15.1.1. A shot for a field goal or a free throw is when the ball is held in a player’s hand(s) and is then thrown into the air towards the opponents' basket.
Therefore, in the scenario you describe, the player is not considered to be in the act of shooting. The foul, unless Unsportsmanlike or Disqualifying, shall be disregarded. The result of the play is:
16.2.2. If a player accidentally scores a field goal in his team’s basket, the goal counts 2
points and shall be recorded as having been scored by the captain of the opponents’
team on the playing court.
The game would resume with a throw-in for team B as after any made basket by their opponent.