Understanding containers and codecs To my understanding, there is the container format (MP4, MOV, 3GP, AVI) and the codecs (Theora, VP8, H264, XVid, DivX).

For what I understand, the container format and the codecs are independent and it seems that it would theoretically be possible to have a MP4 which contains some video encoded with DivX. 

Would it work? I mean, would standard video players be able to play it?

Also, I don't understand why H.264 (a codec) is defined in the MPEG-4 (a container) specification.

As H.265/HVEC is to replace H.264, will there be a new container format? Or will there be some MP4 files containing some videos encoded in H.265?
MPEG-4 is not a container specification. It's a suite of specifications. Parts 12 and 14 define containers (MP4). Part 2 defines a video codec, whose encoder implementations are DivX and Xvid. Part 10 defines another video codec AVC a.k.a. H.264.

You can get a list of codecs, which can theoretically be present in a MP4 at http://mp4ra.org/codecs.html

Whether a given muxer/software offers the feature to include a codec in MP4, or whether a given player accepts a codec in a MP4, depends on the software developer. Generally, MPEG-4 Part 2 should be accepted but players can be finicky about the codec tag and may only play the video if they recognize the tag.

HEVC can be muxed in a MP4 and there's no dedicated or new container for it.