Hi @Deniz Durmus Thank you for posting your question on Microsoft Q&A.
work_mem is assigned per connection so the total RAM used is work_mem * concurrent connectons – thus an upper limit is needed to avoid starving processes.
Also maintenance_work_mem being a background process is designed to have a upper limit so that by mistake we do not over assign the memory and starve other processes.
https://www.postgresql.org/docs/12/runtime-config-resource.html
Hope that answer your question
Regards,
Oury