You can buy a BTO flat if you have not enjoyed more than 1 housing subsidy. This includes buying a flat from HDB, a resale flat with a CPF housing grant, a DBSS flat from a developer, an Executive Condo (EC) from a developer, or receiving other forms of housing subsidy such as SERS.
In summary, you can buy a BTO flat once if you have already enjoyed one housing subsidy.