We sometimes get people complaining about the AF and here are some answers they get - maybe you can apply some to your case:
- AF points are bigger than the little lights in the viewfinder. So sometimes the AF point will nail focus, but not on the object you want, and so AF will be blamed as being faulty
- Slow shutter speed can cause motion blur, which can be mistaken for misfocusing. Make sure the shutter is fast enough
- high ISO can cause noise which makes the image look less sharp. Its best to test AF with a tripod and low ISO
- Lenses and cameras are built to certain tolerances. It can cause a problem if each of them is slightly off in the wrong direction. AF adjustment can help here. You can also use debug mode and change the hidden global adjustment
- Some lenses are so fast that their DoF is very very shallow, which can be mistaken for misfocusing
Here are some other things you can try to improve AF:
- update firmware to the newest version
- make sure lens/mount contacts are clean
- use tripod and live view, try focus peaking, and PD AF to compare the results and pinpoint the problem
- try using a focus chart or focus calibration tools (software, charts, etc.). Some can be found online for free, others have trial versions, and some can be bought
- you can send the camera with the lenses to Pentax and let them "fix it" (calibrate the camera and lenses together). Maybe warranty will cover this
- if you are still under warranty, you can try claiming that the camera is faulty and get a replacement. This can fix the problem, but we have had cases on this forum where the problem was not the camera, so exchanging it didn't fix it
Best of luck