For many of the well studied ODEs and PDEs, there are powerful uniqueness results about solutions. It's much simpler to assume the manipulations are valid, and then justify the manipulations by demonstrating the resulting solution satisfies the differential equation and boundary conditions. If it does- great! If not, we need to think more carefully about the manipulations.
I'd like to give a slightly bigger picture view regarding how this comes about. The 'issues' you ask about are frequent, and very real, but (it is hoped) not insuperable. Many problems come down to an integral of the form
$$\tag{1}
I(a)=\int\limits_{-\infty}^\infty dx \exp(-x^2+a P(x))
$$
For some given function $P(x)$, often a polynomial. For essentially every nontrivial choice of $P$, the integral cannot be done in closed form. We can try something or give up. One thing to try is expanding the second exponential
$$\tag{2}
I(a)=\int\limits_{-\infty}^\infty dx \ e^{-x^2}\left[1+aP+\frac{(aP)^2}{2}+\cdots \right]
$$
If we commute the summation past the integral, the problem is simple!
$$\tag{3}
I(a)=\sum\limits_n\frac{a^n}{n!}\int dx \ e^{-x^2}P(x)^n
$$
Each polynomial times Gaussian may be integrated easily. We're left with a series solution
$$\tag{4}
I(a)=\sum\limits_n C_na^n
$$
And (4) is pretty much guaranteed to diverge. This is because it was not valid to commute the sum and integral to get from (2) to (3) if $a=0$ is a singular point. Example: $P(x)=x^4$, then (1) converges only for $a \leq 0$ and diverges for $a>0$. In a different problem, we might have started with a differential equation, tried a perturbation series solution, and would end up with something very similar to (4). I point this out because: this type procedure is one of the few ways to 'break into' hard problems, and is ubiquitous in physics.
The surprising thing is that (4) is still useful. It may be an asymptotic series and there are methods to 'sum' the divergent series and get a finite result. It is quite difficult to prove things in generality about these techniques, but for a class of problems including those in non-relativistic quantum mechanics, the analog of (4) can be shown rigorously to make sense$^\dagger$. They have also been quite good agreements with experiment, even when the summation cannot be rigorously justified.
Generally, in physics we expect the answers to have a certain 'regularity' or 'niceness'. So even if a manipulation is not fully justified for arbitrary functions, it may be justified for a certain class of nice-enough functions. Fortunately these are the ones we are often interested in.
$\dagger$ This was mentioned in one of Carl Bender's lectures. I'd also highly recommend his book Advanced mathematical methods if any of this sounds interesting.