For BCGs, theoretically any brand AR15 part should function with other brand parts. However some brands have drastically different manufacturing tolerances. That is the +/- deviation allowed from the intended measurements. In some cases trying to fit two parts together can be a pain because one part measures whatever.0190 and you're trying to fit it inside a part that measures whatever.0050 inches.
For rails and barrels, some manufacturers have their own special components. I'm almost entirely certain Daniel Defense uses their own barrel nut, and Noveske does as well, and probably a bunch of other guys as well.
Here's the DD barrel nut.
Here is the Noveske barrel nut.
You can see how they use different methods for attaching the rail, so in order to go from one style to the other you would have to remove the old nut and install the new one.
As for barrel/rail length, that depends on specific parts. With the traditional triangular A2 style front sight gas block it just plain will not fit inside a rail, which means to use it with a rail without modification the rail needs to have a length short enough to fit behind the gas block. However, more than one person has chopped down their FSGB in order to fit a longer rail. Many companies also make Low Profile gas blocks, which usually do not have an integrated front sight post, and are low enough to fit under a rail.
Here is an example A2 front sight gas block.
Here is an example low profile gas block.
You can see how the iconic triangular one is much taller than a low profile one, which limits where it can fit.
However, there are some exceptions, such as this Daniel Defense rail that allows the use of an A2 gas block with a longer rail length.
In terms of function, there's really no reason why you can't have a rail the same length as your barrel, or even a bit longer to make it flush with the flash hider/brake or other muzzle device. You just might have to swap out some parts depending on exactly what you have. I've seen a few guns that had rails the same length as the barrel, for optimum placement of forward mounted flashlights. Otherwise your rifle barrel will cast a shadow due to the flashlight being mounted slightly further back.
An 11.5" barrel inside a 13" rail might actually end up being the same length depending on what muzzle device you have. There's no real reason not to do it. However, it would be a bit tricky to install because you might not be able to get at it with a wrench while the rail is installed.
An example might look like this, though it looks like this one has a 7" rail on it.
For short barrels, especially if you are building it yourself, a very important thing is to verify the necessary gas tube length, and to probably alter the buffer weight or spring strength.
Each barrel has a gas port drilled into it, and that's the spot where you fit the gas block, which means it needs a proper length gas tube. If the tube is too short the gas port will just be puffing gas out into the air rather than into the tube and back to the gas key on the bolt carrier, and if it's too long you can bend or damage the tube trying to get it to fit.
Gas systems come in several sizes, from shortest to longest: Pistol(~10"), Carbine(~16"), and Rifle(~20"). Each one has specific gas tube lengths, and generally each one has it's own preferred buffer weights and spring strengths.
If the buffer/spring are not properly matched to the gas system you can get unreliable cycling if the springs are too strong for the gas pressure or if the fouling has built up and increased friction, or increased wear because the springs are too weak to absorb the impact.
However that's not all the fault of the gas system, as the rifle gets dirty the parts start to experience increased friction. Some fancy guns have very tight tolerances which means that even a little fouling can really throw them off their game, and some cheap guns have loose tolerances which means they don't suffer as much due to fouling build up. It's the age old joke that a $500 Chinese fake M4 is more reliable than a $2000 custom rifle, due to the fact that the cheap one has loose tolerances and can last longer between cleanings without becomming unreliable. It's also part of the old myth that semi-auto guns are less reliable than manually operated ones like a trusty old lever action. That's because the gas system and the springs can only exert so much before they max out, whereas with a manually operated gun you can muscle through it.
Happy building, it's fun stuff.