Within After Effects, by defaultt all compositions nested in a composition continue to play back as long as the main composition is playing back, so if the main composition is looping, the nested pre-comp should also continue looping. Also, if the pre-comp is 5 seconds long and the main composition is 20 seconds long, the 5-second pre-comp will be able to loop 4 times within the 20-second main composition.
Keep in mind that you can loop it all you want in After Effects, but once again, when you say it’s going to “social media,” final control of video playback ultimately depends on the site you upload to. Whether it’s going to loop, and how many times, is up to the specific way that Instagram, Twitter, Facebook, etc. have each coded their sites for video playback. You upload a video to them, after that you let it go and are at the mercy of how those sites handle playback. That’s why the CSS workaround I suggested only works on a web site you control. On web sites you don’t control, those sites control how the video plays back, it’s not the same on every social media site, we often have no options to adjust that, and..…you never know when they will put out an update that changes how it works.
Instead, we have to adjust our presentations so that they will be successful within the lack of control we have over social media playback. Organizations with a bigger budget, or people with more time on their hands, can tailor their presentations for each social media outlet that’s important to them. For one site they might tailor a video to straight playback, no looping. For an Instagram Story they might customize their presentation not only to fit the vertical video format, but to take advantage of the opportunities of that specific outlet, like swiping up for more information or to go to a link.
What is most difficult, or sometimes impossible, for social media is “one solution fits all.” Either it’s one highly simplified solution that works anywhere, or multiple highly customized solutions that take advantage of each outlet’s special features.