COUNT(*) giving wrong results

I am facing a very peculiar issue here. Will take it up with the help of queries -

SELECT COUNT(*) FROM table_name WHERE "column_name" = 'elec';

-- this is giving me 2 rows.

SELECT COUNT(*)

FROM (

SELECT * FROM table_name WHERE "column_name" = 'elec'

);

---this gives 731 rows which is the CORRECT value.

SELECT COUNT(*) FROM (

SELECT * FROM table_name

)

WHERE "column_name" = 'elec';

---this also gives 731 rows which is the CORRECT value.

I have no clue what is I am doing wrong here. It is happening for queries with a 'WHERE' clause. I looked at the PlanViz fir these two queries, but could not make anything out of it. Any help would be appreciated