What determines these rules? For me its always been difficult to memorize them since I don't know the how or why behind it.

Some mathematical rules are descriptive. Like the distributive property, the commutative property, and the associative property. These rules are determined first by recognizing patterns in mathematics, and second by stating a conjecture to generalize the pattern. Finally, the mathematician who discovers this rule will need to construct and publish a formal proof of the general case to show that it is true in all cases. If there are specific exceptions, those exceptions need to be identified as part of the statement of the rule. Specific examples do not prove rules no matter how many you evaluate, but one counterexample proves a rule to be false.

Other rules are prescriptive. Meaning they are true because we define them to be true. Order of operations is one example. In programming, it is called operator precedence. It is the convention of what operator takes priority over other operators. Prescriptive rules are determined as a consensus from patterns in the habits of other mathematicians in history.

The order of operations comes from what order of calculations come more frequently in application, than the alternative. Parenthesis and brackets are defined for overriding the default, so they have to come first. With exponents, it is much more common that you only intend to raise the previous number to the power, rather than everything before it. (-4)^2 ends up being the same thing as 4^2 and would be redundant if the minus is squared first. So if you write -4^2, you likely intend the answer to become negative. It would be a lot less convenient to write -(4^2) every time we intend the negative sign to be applied after the squaring. The motto to remember, "a minus ain't squared, unless it's been snared".

With the precedence between multiplication and addition, think of what you do when you add up cost of items on a bill. You first multiply each quantity with each unit cost, and then add up the line totals. It wouldn't make any sense to add up quantities of unrelated items, and then multiply that by a total of unit costs. It is much more common to multiply first, and then add, in applications of mathematics in general. A concept mathematicians call a dot product, which means multiply corresponding components and then add.