Derivation of $B$ field and $E$ field

You need to have an argument that the relevant field actually diminishes as you go toward spatial infinity. Often this step is omitted when working with the solenoid, although it can be demonstrated without too much trouble. The problem with doing the same for Gauss's Law with an infinite sheet of charge is that the electric field does not get any weaker as you go to spatial infinity. So no matter how far away you put one end of your Gaussian pillbox, the electric flux through then end is always the same.