Subtitles have (almost) nothing to do with the video codec. AVI, MKV, MP4, etc. are container formats that are used to multiplex multiple streams of media (video, audio, subtitles) into a single stream/file. In contrast, AV1, x264, HEVC, etc. are video codecs stored inside a multiplex. Perhaps confusingly, he MPEG LA (which standardised x264 and HEVC) is also responsible for the MP4 container.