With the custom query you can only create static queries, that means you can’t have a part that needs to add a dynamic number of parameters.
For example I have an array of 3 ids and want to select these 3 ids:
SELECT * FROM table WHERE id IN (:P1)
:P1 has the array with ids as value, this will not work, to make it work you need to know the number of parameters you are using.
SELECT * FROM table WHERE id IN (:P1, :P2, :P3)
When each id is put in its own parameter it works, but this only is usable when you know the number of parameters to expect.
So why does it work with the query builder? This is because the query builder builds its query dynamically, it generates the correct sql needed depending on the number of items in the array.