Because they are hiding from people who make large rooms for them to spawn in. Seriously though, all you can do is put it on peaceful. Slimes spawn in any light level at the bottom 16 layers of a map. If you want to stop them, try making the space a little smaller so they wont have room.
Attachments
Comments 3

Thank you for your report!
However, this issue is Incomplete.
Your report does not contain enough information. As such, we're unable to understand or reproduce the problem.
You are welcome to create a new ticket about your issue with more detailed information.
However, please review the Bug Tracker Guidelines and be sure to search for existing issues before writing a new bug report.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
Thank you for your report!
However, this issue is Incomplete.
Your report does not contain enough information. As such, we're unable to understand or reproduce the problem.
You are welcome to create a new ticket about your issue with more detailed information.
However, please review the Bug Tracker Guidelines and be sure to search for existing issues before writing a new bug report.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki