The first equation is linear:
[tex]x\dfrac{\mathrm dy}{\mathrm dx}-y=x^2\sin x[/tex]
Divide through by [tex]x^2[/tex] to get
[tex]\dfrac1x\dfrac{\mathrm dy}{\mathrm dx}-\dfrac1{x^2}y=\sin x[/tex]
and notice that the left hand side can be consolidated as a derivative of a product. After doing so, you can integrate both sides and solve for [tex]y[/tex].
[tex]\dfrac{\mathrm d}{\mathrm dx}\left[\dfrac1xy\right]=\sin x[/tex]
[tex]\implies\dfrac1xy=\displaystyle\int\sin x\,\mathrm dx=-\cos x+C[/tex]
[tex]\implies y=-x\cos x+Cx[/tex]
- - -
The second equation is also linear:
[tex]x^2y'+x(x+2)y=e^x[/tex]
Multiply both sides by [tex]e^x[/tex] to get
[tex]x^2e^xy'+x(x+2)e^xy=e^{2x}[/tex]
and recall that [tex](x^2e^x)'=2xe^x+x^2e^x=x(x+2)e^x[/tex], so we can write
[tex](x^2e^xy)'=e^{2x}[/tex]
[tex]\implies x^2e^xy=\displaystyle\int e^{2x}\,\mathrm dx=\frac12e^{2x}+C[/tex]
[tex]\implies y=\dfrac{e^x}{2x^2}+\dfrac C{x^2e^x}[/tex]
- - -
Yet another linear ODE:
[tex]\cos x\dfrac{\mathrm dy}{\mathrm dx}+\sin x\,y=1[/tex]
Divide through by [tex]\cos^2x[/tex], giving
[tex]\dfrac1{\cos x}\dfrac{\mathrm dy}{\mathrm dx}+\dfrac{\sin x}{\cos^2x}y=\dfrac1{\cos^2x}[/tex]
[tex]\sec x\dfrac{\mathrm dy}{\mathrm dx}+\sec x\tan x\,y=\sec^2x[/tex]
[tex]\dfrac{\mathrm d}{\mathrm dx}[\sec x\,y]=\sec^2x[/tex]
[tex]\implies\sec x\,y=\displaystyle\int\sec^2x\,\mathrm dx=\tan x+C[/tex]
[tex]\implies y=\cos x\tan x+C\cos x[/tex]
[tex]y=\sin x+C\cos x[/tex]
- - -
In case the steps where we multiply or divide through by a certain factor weren't clear enough, those steps follow from the procedure for finding an integrating factor. We start with the linear equation
[tex]a(x)y'(x)+b(x)y(x)=c(x)[/tex]
then rewrite it as
[tex]y'(x)=\dfrac{b(x)}{a(x)}y(x)=\dfrac{c(x)}{a(x)}\iff y'(x)+P(x)y(x)=Q(x)[/tex]
The integrating factor is a function [tex]\mu(x)[/tex] such that
[tex]\mu(x)y'(x)+\mu(x)P(x)y(x)=(\mu(x)y(x))'[/tex]
which requires that
[tex]\mu(x)P(x)=\mu'(x)[/tex]
This is a separable ODE, so solving for [tex]\mu[/tex] we have
[tex]\mu(x)P(x)=\dfrac{\mathrm d\mu(x)}{\mathrm dx}\iff\dfrac{\mathrm d\mu(x)}{\mu(x)}=P(x)\,\mathrm dx[/tex]
[tex]\implies\ln|\mu(x)|=\displaystyle\int P(x)\,\mathrm dx[/tex]
[tex]\implies\mu(x)=\exp\left(\displaystyle\int P(x)\,\mathrm dx\right)[/tex]
and so on.