Indexes are treated as a dependency of a table, similar to a view, so dependencies must be dropped before a table can be dropped. To drop all downstream dependencies of a table (including indexes) instead of manual drop of each object, you can add CASCADE to the end of the DROP statement:
DROP TABLE <table_name> CASCADE;
Otherwise the default behavior is RESTRICT
, which only drops the table and primary indexes if there are no other dependencies.