Have taken some images for a timelapse project and now I want to render the sequence to a video. Usually I have rendered with the format "animation". But lately I learned that I could choose different format, i.e "H.264. But when I do so, I get a message that there is mismatch in settings and that the format will be change from 4096x2731 to 2000x2000 to meet format restraints. Why does this happen? Why can't I render in 4096x2731 in H.264?
Compressed formats have specific algorithms and optimizations that limit their available resolutions, framerates and so on. You need to read up on that stuff and which specs are allowed within which formats, MPEG levels and which encoders and playback programs support which spec. You also cannot use "crooked" values to begin with. An odd size like your 2731 will always be padded to be 2732 or cropped to 2730 since all MPEG footage needs to have dimensions that are multiples of 2, 4, 8, 16 and 32 - again inherent in how the compression works. There's lots of info on this on the web. Just study up.
Also, you should not render H.264 files out of After Effects - it can't even do multi pass encoding! Use the Adobe Media Encoder. But, as Mylenium says, you have to do it at "correct" values.