If you are using pg_class to find all indexes, you need to join that to pg_namespace and filter on the schema where your tables (and indexes) are stored.
It is much easier to pg_indexes instead though:
select schemaname,
indexname,
tablename,
format('drop index %I.%I;', schemaname, indexname) as drop_statement
from pg_indexes
where schemaname not in ('pg_catalog', 'pg_toast');
That will however also show you indexes that are used for primary keys.
If you want to exclude primary key indexes, you can use something like this:
select s.nspname as schemaname,
i.relname as indexname,
t.relname as tablename,
format('drop index %I.%I;', s.nspname, i.relname) as drop_statement
from pg_index idx
join pg_class i on i.oid = idx.indexrelid
join pg_class t on t.oid = idx.indrelid
join pg_namespace s on i.relnamespace = s.oid
where s.nspname not in ('pg_catalog', 'pg_toast')
and not idx.indisprimary;
If you also want to exclude unique indexes, just add and not idx.indisunique to the where condition.
drop tabledrops a table not an index. Your query returns indexes. It is unclear to me, what exactly you want to drop: any table that has an index or just all indexes?