Well, I work mostly in Photoshop, and it has a few things that make these lines and shapes possible. Firstly - the lasso tool, polygonal lasso can be used to draw the outline of the shape, and then painting is enabled only in that area, so you get the sharp edge. Just like masking in traditional painting, or using a ruler.
Secondly - the path tool in shape mode, and the line tool are some things I use. Lines in raster mode, paths in shape mode so I can edit them. I have a lot of experience with those.
I really do a lot of geometric stuff for work, so I developed the feel for it. Tools like the lasso only make it easier.
Also, I work in high resolution, and you can always use the sharpen tool for areas you need sharpened, but save that for the post-production if you're new to everything.
You can make straight lines with the brush tool by holding shift, but that only gets you horizontal and vertical straight lines. Anyways, everything requires practice, and practice makes better. Have a nice day.