This can be done without hardcoding the columns in the formula. I am going to show you how to make a formula that can work with any number of columns without any change to the formula.
We are going to have the filter checkboxes in the first row. I filled the whole first row with checkboxes.

Note that in Google Sheets we can refer to the whole first row as 1:1
, we will rely on this.
For the QUERY formula we need to be able to compute the column letters. Google Sheets does not provide a direct way to get just that, so we have to get creative. We can get the column indexes (1, 2, 3, ..), and then we can convert them to single cell addresses ($A$1, $B$2, ..), and then we can filter out the non letter characters, and we got ourselves some clean column letters:
We reuse the previous formula, and for all unchecked checkboxes, we replace (with IF) the column letter with an empty string, and TEXTJOIN whatever remains:

(The TRUE in TEXTJOIN ensures that the empty strings are ignored.)
We get the needed query by just appending "SELECT " to the previous formula:

And the whole formula comes together like this:

That's it.
Make sure to always provide the "header" parameter to the QUERY function, you don't want it guessing.