What is CS and PS out-of-equilibrium at $P=30$:
I think that answer to this question lies in misunderstanding the definition's of consumer and producer surplus.
The consumer and producer surplus are actually (following Mankiw Principles of Economics, 8th ed, pp 135 and 140
consumer surplus:
the amount a buyer is
willing to pay for a good
minus the amount the
buyer actually pays for it
producer surplus
the amount a seller is
paid for a good minus the
seller’s cost of providing it [where Mankiw later in chapter explicitly states cost is here to be interpreted broadly as "the value of everything
a seller must give up to
produce a good", including the opportunity cost (or more broadly s wilingness to sell)].
You will note that the definitions above talk about price people pay (i.e. actual market price) not 'equilibrium price'. Some lecture notes or textbooks will include the word equilibrium in the definitions but that is only because virtually all analysis using Supply-Demand is an analysis of some equilibrium.
More rigorously, since the maximum willingness to buy is bounded by the demand curve and willingness to sell by supply curve we can define consumer surplus as the area below the demand curve and above price paid by consumers and
$$CS = \int^{q_m}_0 D(q) dq − p_mq_m $$
where $D(q)$ is arbitrary demand curve, $p_m$ is price consumers have to pay in the market, and $q_m$ quantity sold at the market.
$$PS = p_mq_m - \int^{q_m}_0 S(q) dq $$
wher $S(q)$ is some arbitrary supply curve (also if we would want to be even more general we could allow $p$ to be different for suppliers and consumers e.g. situations with taxation where there would be wedge between price consumers pay and price per quantity suppliers get due to the tax wedge).
Yes, in some chapters or lecture notes the above formula will be defined in terms of equilibrium price but that is only because the market price/quantity is the equilibrium price/quantity in any equilibrium analysis (i.e. in equilibrium $p_e = p_m, q_m=q_e$).
However, in an out-of-equilibrium analysis you have to use actual market prices (this would be equivalent of analyzing price floor or price celling (e.g. see Mankiw Principles of Microeconomics, 8th ed, pp. 116).
Consequently, in your case the consumer and producer surplus can be properly visualized as shown on the tikz graph below I made:

where the area of consumer surplus (out-of-equilibrium) at price $P_m=30$ is the blue shaded region below demand and above market price bounded by market quantity, and the producer surplus (out-of-equilibrium) at price $P_m=30$ is the red trapezoid (area under the market price and above supply bounded by market quantity).
We can also calculate the area of that trapezoid, although to do that we need to know what is the price at which $Q_S=0$ (or explicitly know what the supply and demand equations are). In your question you don't state what the price at which supply is equals zero is but if you would provide it we could calculate it (also you seem to have made some mistake when copying down the problem as your demand does not lie on a line since it is given by points $(0,40);(15,30);(20,20)$ - which simply mathematically cannot lie on a single line - I originally planned to go all the way deriving the linear demand and supply equations based on the points but this mistake in problem set up makes it impossible ).
Why is total welfare maximized in equilibrium?
Well the reason for this is that under all the background assumptions of the stylized partial equilibrium model (e.g. no market failures and other 'shenanigans' that would affect PS and CS in way not shown in the partial equilibrium analysis here), the total combined area of PS and CS is maximized at the equilibrium price and quantity.
I won't be providing a rigorous proof of this as that would require a lot of calculus and this problem is long as it is, but I encourage you to take a look at proofs provided in MWG, Microeconomic analysis pp 328 or Varian, Microeconomic Analysis pp 224 if interested.
However, the reason why the welfare be easily seen graphically by the following thought experiment: would the total surplus be larger if $P>P_e$ or if $P<P_e$? The answer is no as you can see visualized in the two figures below. As in both figures below the total surplus area will always fit within the big triangle given by area below demand and above supply clearly the total welfare is in both situations lower than the total welfare in a situation where $P_m=P_e$.

PS: An important caveat to note is that the above applies when you want to analyze what would be the total welfare outside equilibrium vs the welfare in equilibrium. If you want to compare two situations which are both equilibrium e.g. supply shifts to the right due to technological progress, you have to compare the total welfare in the market in the old equilibrium vs the new one. You should not confuse such situations with market not being in equilibrium.