Mac running macOS Mojave doesn't boot
I run fsck -fy three or four times, as suggested in the comments, but it didn't reveal any issues and kept telling me  "The volume /dev/rdisk1s1 appears to be OK".

I was lucky to have Windows installed alongside macOS with Bootcamp, so I booted into Windows to see whether the data on the macOS partition were fine. It turned out that one can't just view APFS drives in Windows, so I had to install a trial version of APFS by Paragon, which allows you to mount such drives from Windows.

The partition mounted successfully, and I was able to see all my data, so, apparently, nothing was lost or corrupted. I was even luckier to have a spare hard drive lying around and a device to connect it to a computer through USB, so I did that and copied the vast majority of my files from the (faulty?) macOS partition to this drive.

After the data were safe, I rebooted into Recovery mode, checked the partition from Disk Utility once again, which showed "...appears to be OK" again, and tried to reinstall the OS.

I know the installation process is supposed to be kinda long, but this one was insanely long. Everything seemed to have installed (no errors whatsoever), and it attempted to boot itself. It was doing that and showing me the usual apple logo on the white background and a full progress bar for literally fifteen hours because I was told to "let it work" and that it might repair the drive in the comments, and was hoping not to lose any data. Well, that went nowhere, so finally I just shut the Mac down. (BTW, after booting from Windows again I found out that all the data on the macOS partition were still intact)

I ended up wiping the macOS partition from the Disk Utility in the Recovery mode and installing macOS once again. This worked fine, and I got a fresh macOS Mojave installation, from which I'm writing this (semi-)answer. I can access all the data I copied to the external drive, nothing is corrupted.



TL;DR - did a backup (the partition was not corrupted), nuked the partition from orbit and did a clean installation; still no idea why this happened.