Automated multiplexer in vhdl
The variable counter is actually a register, so you must describe it in the first process which is clocked. You cannot describe it in the second process, because you have less control on how often this process is resumed during the same clock cycle. The process is resumed whenever one of the signals in the process sensitivity list changes. I also prefer signals instead of variables because in most simulators you can add only signals to the waveform for debugging.

To control a counter register in the first (clocked) process from the second process, you need two control signals: counter_rst when the counter should be reseted, and counter_inc when the counter should be incremented.
The counter in the first process can then be described with:

    if (CLK' event and CLK = '1') then
        if counter_rst = '1' then   -- you may add RST and/or START here
            counter &lt;= 0;
        elsif counter_inc = '1' then
            counter &lt;= counter + 1;
        end if;
    end if;


You may add RSTor START on the first condition to fit your needs.

For example, the counter is now incremented when you assign counter_inc &lt;= '1'; in the second process. This replaces the assignment of counter := counter + 1; in your current code. If no increment is needed, then you must assign counter_inc &lt;= '0'. This is accomplished by making a default assignment at the start of the process. The control signal counter_rst is handled in a similar way. The counter must be added to the sensitivity list of the second process, because you want combinational logic here.

You also have to fix the counter checks. If you want to count 3 pulses, then you must count from 0 to 2.

Your code also needs a default assignment for new_state, because you didn't assigned a new value in each branch in the second process. In the last process it must read MUX_OUT instead of MUX, also A and B must be added to the process sensitivity list. Otherwise you get a latch.

This is the whole fixed code:

library ieee;
use ieee.std_logic_1164.all;

entity FSM_MUX is
    Port ( CLK : in STD_LOGIC;
           RST : in STD_LOGIC;
           A: in STD_LOGIC;
           A_INT : in STD_LOGIC;
           B: in STD_LOGIC;
           B_INT : in STD_LOGIC;
           START : in STD_LOGIC;
           MUX_OUT : out STD_LOGIC);
end FSM_MUX;

architecture Behavioral of FSM_MUX is

    type state is (iddle,state_A,state_B) ;
    signal old_state : state ;
    signal new_state : state ;
    signal counter : integer range 0 to ((2**16)-1) := 0;
    signal counter_inc : std_logic;         -- increment counter
    signal counter_rst : std_logic;         -- reset counter

begin
    process(CLK)
    begin   
        if (CLK' event and CLK = '1') then
            if RST = '0' or START = '0' then
                old_state &lt;= iddle;
            else
                old_state &lt;= new_state;
            end if;

            -- counter register
            if counter_rst = '1' then   -- you may add RST and/or START here
                counter &lt;= 0;
            elsif counter_inc = '1' then
                counter &lt;= counter + 1;
            end if;
        end if;
    end process;

    process (old_state, A_INT, B_INT, counter)  -- added counter
    begin
        counter_inc &lt;= '0';             -- default assignment ...
        counter_rst &lt;= '0';             -- ... may be overwritten below
        new_state   &lt;= old_state;

        case old_state is
            when iddle =&gt;
                if A_INT = '1' then
                    new_state &lt;= state_A;
                else
                    new_state &lt;= iddle;
                end if;

            when state_A =&gt;
                if A_INT = '1' then
                    if counter &lt; 2 then      -- count from 0 to 2 for 3 pulses
                        counter_inc &lt;= '1';  -- increment counter
                        new_state &lt;= state_A;
                    else
                        counter_rst &lt;= '1';  -- reset counter
                        new_state &lt;= state_B;
                    end if;
                end if;

            when state_B =&gt;
                if B_INT = '1' then
                    if counter &lt; 4 then      -- count from 0 to 4 for 5 pulses
                        counter_inc &lt;= '1';  -- increment counter
                        new_state &lt;= state_B;
                    else
                        counter_rst &lt;= '1';  -- reset counter
                        new_state &lt;= state_A;
                    end if;
                end if;
        end case;
    end process;

    process(old_state, A, B)            -- added A and B 
    begin
        case old_state is
            when iddle   =&gt; MUX_OUT &lt;= '0';  -- MUX_OUT instead of MUX !
            when state_A =&gt; MUX_OUT &lt;= A;
            when state_B =&gt; MUX_OUT &lt;= B;
        end case;

    end process;
end Behavioral;


This was my testbench:

library ieee;
use ieee.std_logic_1164.all;

entity FSM_MUX_tb is
end FSM_MUX_tb;

architecture sim of FSM_MUX_tb is

    signal CLK     : STD_LOGIC := '1';
    signal RST     : STD_LOGIC;
    signal A       : STD_LOGIC;
    signal A_INT   : STD_LOGIC;
    signal B       : STD_LOGIC;
    signal B_INT   : STD_LOGIC;
    signal START   : STD_LOGIC;
    signal MUX_OUT : STD_LOGIC;

begin  -- sim

    DUT: entity work.FSM_MUX
        port map (
            CLK     =&gt; CLK,
            RST     =&gt; RST,
            A       =&gt; A,
            A_INT   =&gt; A_INT,
            B       =&gt; B,
            B_INT   =&gt; B_INT,
            START   =&gt; START,
            MUX_OUT =&gt; MUX_OUT);

  -- clock generation
  CLK &lt;= not CLK after 10 ns;

  -- waveform generation
  WaveGen_Proc: process
  begin
      RST &lt;= '1';                       -- low-active, optional
      START &lt;= '1';

      A &lt;= '0';
      B &lt;= '1';
      A_INT &lt;= '0';
      B_INT &lt;= '0';

      -- leave IDDLE state
      wait until rising_edge(CLK);
      A_INT &lt;= '1';
      wait until rising_edge(CLK);
      A_INT &lt;= '0';

      -- just some waiting
      wait until rising_edge(CLK);
      wait until rising_edge(CLK);

      -- 3 A_INT pulses to leave STATE_A
      for i in 1 to 3 loop
          wait until rising_edge(CLK);
          A_INT &lt;= '1';
          wait until rising_edge(CLK);
          A_INT &lt;= '0';
      end loop;  -- i

      -- 5 B_INT pulses to leave STATE_B
      for i in 1 to 5 loop
          wait until rising_edge(CLK);
          B_INT &lt;= '1';
          wait until rising_edge(CLK);
          B_INT &lt;= '0';
      end loop;  -- i

      wait;
  end process WaveGen_Proc;
end sim;


And this is the simulation output: