I used to think dmesg command shows the contents of /var/log/dmesg when executed, is that right?
That depends on the distro's implementation.
I've seen systems that do a ring buffer dump right after the boot and the content is placed in /var/log/dmesg. Other distro's dump as well, but place it in a more appropriate named file: /var/log/boot (or alike).
These files are a static representation of your system, just after booting is done and syslogd takes over the logging. If syslogd is set up correctly, all messages are put into the appropriate files.
Hope this helps.