If you have an inefficient stroke you will tire more easily. There are several factors building your endurance:
Improve your body position and streamlining
Increase your surface area for propulsion
Decrease your surface area for resistance
Improve your floating skills to relax your recovery muscles
To swim farther and faster with less energy expenditure (stamina), or be able to swim harder to build your strength to apply more force over time (endurance), I suggest you first do this step sequence:
Do several push offs and glides for distance marking where you stop to improve your streamlining and floating to decrease resistance
Swim several strokes without breathing with goggles to see your hand catch and arm rotation to increase your surface area
Work on increasing longer force application with more distance per stroke
These factors together allow you more time to exhale and inhale more air to supply your working muscles. And because your focus is on floating you can relax your arms on the recovery phase.
Now comes the hard part. Your body adapts to stress by increasing the load placed upon it. To increase your endurance and stamina do Interval Training.
Keep your stroke mechanics but swim shorter distances faster to put a load on your muscles to get stronger. Swimming easy at a submaximal steady state will not help unless you plan on swimming a mile or two to build your endurance.
For example, your heart is also a muscle. It’s a pump that shunts oxygenated blood to your working muscles. If the effort is low pressure you will not open up capillaries to supply oxygen to your working muscles or carry away the by-product – lactic acid.
To build stamina (strength) and endurance always warm up with some yardage/meters at only 40-60% effort. Then do repeat sets where you rest the same amount of time as you worked.
If you want more endurance shorten your rest time and/or lengthen your repeat distance or total number of repeats. But first get good stroke mechanics to be more efficient, and that includes better floating and streamlining skills, too, for more distance per stroke.