Getting the idea for your paper/study may come through a combination different sources:
Discussion with you MSc/Phd advisor or collaegues
Literature review, eg using Google Scholar, Web of Science or the Scholar AI within ChatGPT for finding papers. It is a good idea to find a highly cited paper in your field/topic and then explore which papers recently cite that classic paper. Then you make sure you do not duplicate recent research efforts. Organize your references through a reference manager, like Zotero. In your reference manager, you may make a list of main topics and subtopics under each main topic
Brainstorm on the subject with an AI, like ChatGPT. What works often surprisingly well is to write a short summary of your topic, what you plan to do. And then ask: "What would be the next steps in this research agenda" - then explore further with brainstorming, asking explanation on terms that you do not know, etc.