Find the principal functional group before numbering the parent chain. Look at what the key atom is bonded to: an aldehyde carbonyl carbon carries H; a ketone carbonyl carbon carries two carbon groups. A carboxylic acid has carbonyl carbon bonded to OH. A nearby oxygen does not make every carbonyl an ester.
Worked example
Same formula, different family
Compare CH₃CH₂CHO and CH₃COCH₃. Which is an aldehyde?
CH₃CH₂CHO is propanal: H is directly attached to the carbonyl carbon. CH₃COCH₃ is propanone: its carbonyl is between two carbon groups.
What changes when you draw the exact same connectivity rotated on the page?
Nothing about the molecule's name. A different drawing direction is not a different connectivity.