Good Morning and welcome. I am Dr. Loretta, a licensed veterinarian and I am happy to answer your question.
Poor Milo may be suffering from a condition called Paraphimosis. This means that he cannot get his penis back into the sheath after erection easily and this is causing him pain. At this point , it is not serious because he is able to retract the penis into the sheath but if it gets stuck out, this can cause serious issues for him.
There is no treatment for thsi but neutering will decrease the amount of erections and therefore decrease his risk and pain.
This LINK will give you more details.
Does that make sense to you?
Please let me know if you have ANY other questions. My goal is to give you 100% satisfaction and if you are not yet satisfied, please Reply so I can clarify for you
Sincerely, Dr. Loretta