Kernel Methods for Multistage Causal Inference: Mediation Analysis and Dynamic Treatment Effects