Short answer
While other answers describe why the company could be losing money in the broader sense, in the narrow sense, the company is losing money because its expenses exceeded its revenues for accounting purposes.
The three main factors seem to be (1) a significant decline in revenues from 2022 to 2023 (presumably for the reasons stated in the other answers), (2) a dramatic increase in debt service payments after a previous great decline in debt service post-war (presumably because debt payments were suspended post-war and then resumed), and (3) a surge in non-operating losses other than debt services (presumably write offs from Ukrainian military strikes on oil and gas facilities in Russia that destroyed company property).
The growth in the value of the company's investment portfolio is probably not reflected in its profit and loss statement, because that growth reflects an increase in investment security prices rather than actual sales and purchases of investment seccurities.
Long answer
The financial statements of the company through 2022 and with a partial year financial statement for 2023 are available here.
It's costs of goods sold is about 40% of revenue. It's overhead expenses are also about 40% of revenue. So, its operating income is about 20% of revenues. Its interest expenses less interest income (i.e. net debt service) is about 11% of revenue. So, its operating income less debt service is about 9% of revenues.
Presumably the bottom line goes from a 9% of revenues net profit to a roughly 9-10% of revenues net loss at the bottom line, due to other non-operating losses net of other non-operating income.
Costs of goods sold and overhead expenses were both fairly stable pre-war v. post-war. Falling revenues from 2022 to 2023 cut operating income (i.e. gross revenue less cost of goods sold less overhead expenses) roughly in half.
Debt service fell dramatically post-war prior to 2023, presumably because Russia stopped paying interest on its bonds to foreign investors. But debt service surged in 2023, presumably because Russia starting making interest payments on its bonds to foreign investors again (although I have no evidence other than its financial statements that this is actually what happened). This article (pay per view) tends to confirm that bond payments have resumed, although I was not able to read the whole thing.
The other net non-operating losses could include sanction related impacts on the company's investment portfolio. But, this probably isn't the main factor because its investment portfolio has actually increased in value. Instead, the growth in the company's investment portfolio to $31 billion probably isn't reflected in the financial statements, because the $31 billion figure is probably a fair market value of the portfolio, while the profit and loss and balance sheet figures for the company would be on a cost basis and wouldn't change due to increasing investment security prices in the absence of the sale of those investment securities. How to account for investment securities with a readily determinable fair market value is an ongoing point of controversy among financial accountants.
Non-operating losses could also include, as the question suggests, things like writing off Nord Stream for accounting purposes (although that write off should have been taken in the year it occurred, since the company has an accrual rather than cash based financial accounting system). There has, however, been an upswing in Ukrainian military attacks on Russian oil and gas infrastructure (which is a point of contention with U.S. politicians who don't like this tactic), and there may be write offs of the facilities damages in that way that account for the bulk of the company's non-operating losses that don't involve debt service.