I think the key here is to manage your expectations properly. Normal servicing is not really all that expensive, but its when the cars get a bit older, and things above and beyond just changing oil, plus and filters that need doing that can push the cost up a bit. Having said that, one can be smart about it, and often high quality parts can be purchased from the aftermarket, and fitment done by independent specialists at good labour costs, OR you can DIY.
If you are going ot buy an E46, these cars are now more than 10 years (mostly), and the problem is that most of the used examples will come with a backlog of maintenance that needs doing, unless you manage to find an enthusiast owned example. Just a word of warning, the E46 318i (N42) and 120i (N46) are not exactly renowned for their reliability.. they tend to develop many oil leaks and the valve stem seals usually need doing somewhere upwards of 100 000km. Having said that, Leo Haese are running a very competitive special for valve stem seals on those motors (R7900).
Maybe a good starting point is to find a specialist nearby you who can guide you with things to look out for on the models taht you are considering. Alternatively, the internet is filled with a ton of information on what to expect in terms of maintenance.