Assuming NFL rules here:
For situation 1, see Rule 6 (Free Kicks), Section 1, Article 4 (d) (1).
(d) The ball is dead if:
(1) it is caught or recovered by a player of the kicking team. If the catch or recovery is legal, the ball belongs to the kicking
team at the dead ball spot.
Assuming the kicking team actually gains possession in the field of play, the ball is dead. Kicking team will have the ball at the point of possession. No touchdown or touchback.
For the other situation, by mentioning a muffed kick I assume you mean the receiving team has touched the ball. Then see Rule 9 (Scrimmage Kicks), Section 3, Article 2 and this is basically the same as the previous situation.
ARTICLE 2. KICKERS CATCH OR RECOVER BEYOND LINE. When the kickers catch or recover a kick beyond the line of
scrimmage, the ball is dead at the spot of recovery, even if a member of the receiving team has first touched the ball.
Assuming possession is inbounds, then no touchdown or touchback.