Why exactly is Newton’s Second Law valid only in non-accelerating frames? A reference frame where Newton’s second law is valid is called an inertial frame of reference. Force is absolute, so is mass(for sufficiently small speeds), so if a frame  is to measure an acceleration $a_1=\frac{F}{m}$, given a frame $F_1$ measures acceleration $a$, there will always be such a frame accelerating with respect to $F_1$ so $F=ma_1$. What I don’t understand is, why does this new frame have to be at rest or moving with a constant velocity. In other words, why is Newton’s second law only valid in non-accelerating frames? And this frame is to be  non-accelerating w.r.t which frame?  I have studied this as a definition but couldn’t quite grasp the intuition.
 A: Newton's 2nd law is valid for this frame as well because in reality, Earth is also an accelerating frame. However, non inertial frames with respect to Earth are treated a bit differently: since
the observer themself is accelerating, they will observe that other objects are accelerating in opposite direction with respect to them. That's what you study in relative motion. Hence, a pseudo force has to be taken in account to satisfy the above anomaly.
A: There are a number of problems with 'pseudo-forces', forces that arise due to accelerating reference frames. I would say the most important one is that violates momentum conservation which in turn means it violates Newton's third law $\mathbf F_{12}=-\mathbf F_{21}$.
As an example consider an apple falling to the earth in an inertial reference frame. In this frame the force that the earth exerts on the apple is matched by an equal but opposite force from the apple. Both the earth and apple accelerate towards their center of mass, only the apple is accelerating faster because of its lower mass.
Now consider the frame of the apple. In that frame the apple is stationary but the earth is accelerating quite fast. This means the earth, which weighs over $10^{24}\,\text{kg}$, is gaining momentum at an insane speed. Where does this momentum come from? Not from the apple. The reason this issue appears is that we are working from an accelerating reference frame.
A: The problem with accelerating frames is that the mathematics you need to use to keep track what is really accelerating becomes very messy and counter intuitive. Imagine you accelerate down the street in your car. In your accelerating frame, you are at rest, but everyone else in the world around you is suddenly accelerating in the other direction with no apparent force having been applied to it. Hence the simple expression F=ma cannot describe your perception of the behaviour of all the buildings etc you see from your car. To you, they all appear to be accelerating at a fixed rate. Of course you can find a way to model that by introducing a fixed acceleration term A, and using an equation such as F=m(a-A), but if you do that you are, mathematically doing the equivalent of reverting to an inertial reference frame. And you can imagine that things can more complicate if the accelerating frame is not accelerating at a constant rate.
You also ask with respect to which frame should an inertial frame not be accelerating. The answer lies earlier in your question when you say that acceleration is absolute. Which means that an inertial frame should be non-accelerating with respect to any other inertial frame (ie any frame with an absolute acceleration of zero).
A: Every statement about Newton's Laws without explicitly stating how the different dynamical quantities are defined is at risk of ambiguity.
The definition  "A reference frame where Newton’s second law is valid is called an inertial frame of reference." requires a proper definition of force.
It is a valid definition only if forces are not defined through $F=ma$. The definition implicitly assumes that forces have an independent definition, originating only from the mutual interaction between physical bodies. Under such hypotheses, the validity in an inertial reference frame and the invariance of force and acceleration when moving to other reference frames at rest or moving with a constant velocity ensures the validity of the Second Law in every inertial frame. More formally, if positions in two reference frames are connected by the relation
$$
{\bf r'}(t) = {\bf r}(t) +  {\bf r}_0 + {\bf v}_0 t \tag{1}
$$
with ${\bf r}_0$ and ${\bf v}_0$ independent of time, we have
$$
\frac{{\mathrm d^2}{\bf r'}}{{\mathrm d}t^2} = \frac{{\mathrm d^2}{\bf r}}{{\mathrm d}t^2} .
$$
Adding the invariance of the forces ${\bf F'}={\bf F}$, we get the invariance of Second Law with respect to transformations expressed by equation (1).
Things would be different and would require a different definition of the inertial frame, if one would take $F=ma$ as the definition of force (as it is done in Mach's approach).
A: In an accelerated frame like a car you would see objects accelerating under no external force.  That's because  General relativity tells us Newton's 2nd law is actually more like
$$F=ma+(\text{curvature})$$
Where the curvature term includes gravity and accelerated reference frames.   Newton's law is valid when the 2nd term is negligible (approximately zero curvature).
EDIT: A bit more detail.  You correctly mention that Newton's law is valid in non-accelerated frames. The first term encompasses the accelerated motion (change in momentum) of the object in the frame.  The second term accounts for the acceleration of the frame itself.  The whole thing is called a covariant derivative if you want to know. But formula we know as Newton's 2nd law is the case where the 2nd term is zero, which only happens if the frame's acceleration is zero, i.e. the frame is inertial.
EDIT 2: Note, I wasn't entirely happy with the word "curvature" for the 2nd term, but thought it sufficed for the conceptual purpose. Perhaps more accurate would be:
$$\frac{F}{m}=a_{\text {body}}+a_{\text {frame basis}}$$
A: lets look at this two cases

I)
To obtain the equation of motion with Newton second law , you must give the components of the position vector $~\mathbf R~$ and the components of the external force $~\mathbf F~$in inertial system
with
\begin{align*}
 &\mathbf{R}=\left[ \begin {array}{c} x-{x'} \left( t \right)
\\ y\end {array} \right]
\end{align*}
Newton second law
\begin{align*}
 &m\,\mathbf{\ddot{R}}=\begin{bmatrix}
                         F_x \\
                         F_y \\
                       \end{bmatrix}\quad\Rightarrow\quad
m \begin{bmatrix}
     \ddot{x} \\
     \ddot{y} \\
   \end{bmatrix}
= \left[ \begin {array}{c} m{\frac {d^{2}}{d{t}^{2}}}{x'}
 \left( t \right) +F_{{x}}\\ F_{{y}}\end {array}
 \right]
\end{align*}
II)
Newton second law
\begin{align*}
 &m\,\mathbf{\ddot{R}}=m \begin{bmatrix}
     \ddot{x} \\
     \ddot{y} \\
   \end{bmatrix}=\begin{bmatrix}
                         F_x \\
                         F_y \\
                       \end{bmatrix}
\end{align*}
hence the EOM's case I and case II are equal only if
$$\frac{d^2}{dt^2}\,x'(t)=0\quad \Rightarrow\quad
x(t)=v\,t\quad,\text{v constant}$$
this means that two coordinate system S and S' are "inertial systems" only if they move with constant velocity $~v$  relative to each other
edit

why is Newton’s second law only valid in non-accelerating frames

you can applied  Newton’s second law  also for accelerating frames (case I) , the only restriction is that the position vector and the sum of force vectors  must be given in inertial frame
A: The second law has to be understood in the context of the first law.
The first law says what an intertial frame is: a frame in which an external force is necessary to cause an acceleration. This is a definition. Some say that the first law also postulates that intertial frames do in fact exist.
The second law says what the mathematical relationship between force and acceleration is in an inertial frame, namely $F = ma$. It has nothing to say about what happens in non-inertial reference frames.
We can notice that something really does go wrong in non-inertial reference frames. For example, in a rotating reference frame, we observe an acceleration away from the rotation axis absent any force with an identifiable physical origin. Clearly, then, the relationship $F = ma$ cannot always hold in non-inertial reference frames. In a rotating reference frame we can have $a \neq 0$, but $F = 0$.
Now there is a subtlety here. What is a force? Is a force something that we can trace to a physical origin (electric, strong, weak, gravitational)? That seems somewhat problematic. What about forces which have a physical origin that we haven't identified yet? Is a force anything that produces an acceleration, i.e. do we make $F = ma$ our definition of force? If we do this, then we'll find that the second law is valid in any reference frame. But now how do we distinguish between "forces" that are really artifacts of a non-inertial reference frame and honest-to-goodness forces like the Lorentz force? General relativity is the first step toward an answer.
A: "so if a frame is to measure an acceleration a1=Fm, given a frame F1 measures acceleration a, there will always be such a frame accelerating with respect to F1 so F=ma1. What I don’t understand is, why does this new frame have to be at rest or moving with a constant velocity. In other words, why is Newton’s second law only valid in non-accelerating frames?"
Let there be a bus moving with constant acceleration a.
Imagine yourself to be standing on the road. You are frame 1. Let's say you measure the acceleration to be 10m/s^2 towards the LEFT.
Now suppose there is another girl standing on the road. She is frame 2. She should also measure the acceleration to be 10m/s^2 towards the LEFT.
Note that the girl is at rest or in non accelerated motion w.r.t you. So frame 2 is a frame which is at rest w.r.t you.
Now suppose there is a woman who is walking at uniform velocity. She is frame three. She will also see the bus accelerating at 10 m/s^2 towards the LEFT So frame 3 is moving with constant velocity wrt to frame 1.
But suppose there is a car also moving at constant acceleration of 10m/s^2. The car is frame 4. The car will see the bus at either rest (if they both had same initial velocity) or at constant velocity.  So this observation is not matching with frame 1's observation.
Suppose there is another bike moving at 10m/s^2 towards the RIGHT of first frame, or in other words you saw the bike moving towards the RIGHT with 10m/s^2. Remember the bus is moving at 10m/s^2 towards the LEFT w.r.t you. So again, the acceleration of the bus according to the bike will be 20m/s^2.
Similarly there will be infinite number of frames giving different accelerations of the same bus.
But only the values of the accelerations given by the second and third frame (the girl and woman) will match with the acceleration given by you or the first frame.
This is what the statement means.
A: This new frame have to be at rest or moving with a constant velocity, for $F(x_1-x_2)=m_1x_1’’$ to still apply:
$$ F\left(\left(x_1-\frac12at^2\right)-\left(x_2-\frac12at^2\right)\right) \neq m_1 (x_1-\frac12at^2)’’ $$
Other reference frames exist, but since Newton’s laws don’t apply (without pseudo-forces), there may be fewer interesting things we can say about them.
Perhaps it is unsatisfactory that we have to establish a unique, first, most important reference frame, with respect to which all other frames are compared. Perhaps there is no beautiful reason the 0° longitudinal prime meridian is where it is, but we do need one to talk about location.
