The short answer to your question is, yes. The military CAN provide experience for you to use to get into the FBI or being a detective, but there are caveats and exceptions to this that you should be aware of.
You have a few different options within the military that can provide a segue into working in the FBI or as a detective. You mentioned the Army specifically, but each service has their own criminal investigation department. I served in the Air Force and ours was the Air Force Office of Special Investigations. The Navy, perhaps, has the most well-known version, Naval Criminal Investigative Service, made famous by the TV show of the same name. The Army has the Criminal Investigative Command.
They all do generally the same types of work, but can vary from investigations, counter-intelligence, counter-terrorism, fraud, drug enforcement, and even some undercover work. They will often partner and work with local, state, and federal law enforcement agencies depending on the type role and case they are working on. To become one of these types of agents, you will be sent through FLETC (Federal Law Enforcement Training Center) to get some of your initial training.
Most of the local, state, and federal law enforcement agencies will honor, reward, or otherwise favor any military experience, but MOS/AFSCs within the organizations I listed above will be viewed even more favorably as they are almost a direct correlation.
Another option could be the Intelligence MOS/AFSCs. For example, in the Air Force it would be 14N for officers or 1N0 for enlisted. You spend most of your time doing analysis, looking at information and trying to piece the story together and predict possible outcomes. This is criminal investigative or detective work, but has a lot of the same requirements in terms of skills and abilities. I've seen people transition from intelligence backgrounds into law enforcement very well (to include the FBI).
For education, anything in Criminal Justice or Legal is helpful. As more and more cases deal with technology, even things like Data Science or Computer Forensics can be helpful to make you stand out.