It would surely be a smart move to support the right partner in quickly starting a new memory factory, precisely to Apple's specifications, in return for a long-term supply agreement? If Apple could secure their memory supply and at a lower cost than all of the their PC and phone competition, it would be hugely beneficial for them.
Production is not trivial, but can be outsourced to several parties.
Can't be any more entrenched than CPUs, GPUs, and broadband chips, which Apple still designs.
And to be clear, the foundry space for CPUs/GPUs is not the same as for RAM, which is printed with much larger feature size in order to lower the costs.
If Apple had the manufacturing capabilities then sure, but they would still be running into the same resource constraints for inputs that everyone else is having nowadays.
At the moment, there are no solutions only responses.