In the absence of any useful information (what commands did you invoke? What steps did you do before?) one can only guess that you followed those instructions:
https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
Which of course only works to build a kernel from a Debian source package or from the Ubuntu git repository.
If you got your sources from kernel.org, as you wrote, they will probably not come with the Debian packaging part, so you need to follow the standard instructions for building a kernel, e.g. here:
https://www.linux.com/topic/desktop/how-compile-linux-kernel-0/
But that means installing an unpackaged kernel directly to your system, and the package manager (dpkg, apt) knows nothing about it and might happily overwrite it or remove it with one of the next regular updates, and your hand-crafted custom kernel might be gone.
So you could prevent this with some tactical apt-mark hold
command, but then you'd never get any security update again; or you could do it the regular Ubuntu way and get the sources from kernel.ubuntu.org and build a .deb package for that kernel and install it.
Notice that trying to use a 5.x kernel on an Ubuntu 18.04 that comes with a 4.x kernel (4.5.0-144 right now) might explode in your face when all kinds of other low-level packages are not compatible to that much newer kernel. This might or might not work. If it doesn't, you probably don't want to rebuild a good part of the distribution which might turn out to be necessary.
Edit: If your priorities are that you need that latest 5.4 kernel, go for a more recent Ubuntu release; if you need an LTS release, 20.04 LTS is a much better starting point, and 21.04 (albeit not an LTS release) is better still.
Every once in a while low-level system packages need to be adapted to work well with a newer kernel; UDEV comes to mind, to name just one. If you use a newer kernel, but still the older UDEV (or other similar low-level subsystems), some system events may be sent in slightly different situations as before, and some tools may break in subtle ways. It doesn't need to be like that, but the possibility exists.
There is a reason why the distribution is released as a whole in certain intervals; the most important thing that a Linux distributor does is to integrate all the different subsystems to work well together. A Linux distribution is not just a bunch of pieces to be thrown together at random, and everything will work out fine; there is a lot of expertise and work involved.
You can increase your chances of things working well if the age of components is roughly the same; but a recent kernel from mid-2021 and all the rest from early 2018 (i.e. over 3 years earlier!) is asking for trouble.
You might get lucky, of course, but this might be pushing your luck.