Players may not do the following acts against an opponent "carelessly":
- charges
- jumps at
- kicks or attempts to kick
- pushes
- strikes or attempts to strike (including head-butt)
- tackles or challenges
- trips or attempts to trip
(I have highlighted the acts relevant to this case)
"Careless" means "shows a lack of attention or consideration when making a challenge or acts without precaution." (Law 12)
If the referee thinks that the attacker's tackle was careless, the attacker commits a foul. Imo, the attacker was not careless (according to the above definition) because he played the ball and did not initiate any contact with the defender; tackling is part of football and players are entitled to tackle opponents.
As a matter of fact, the defender did kick the attacker. The only subjective part is whether the kick was careless. Imo, the defender acts without precaution; accordingly, the defender was careless according to the above definition, and commits a foul.
If the referee thinks that the attacker and defender both commit an offence at the same time, he punishes the most serious offence which I believe to be the kick (note: I don't consider the attacker to have committed any offence at all).