How to get the formulas used by seasonal_decompose for Trend and Seasonality
I do not know how seasonal decompose works, but there is another very similar method that is well described. 

Triple exponential smoothing (other name Holt-Winters method) internally makes a decomposition into trend, seasonal and residual components. But you should always check the decomposition. It always finds the seasonal component even if it does not exist.

Also the decomposition is actually sensitive to the underlying model. If the data is linear in logarithms and you do not apply a logarithm you will get a much less precise decomposition.